Development Environments#
This guide will walk you through setting up a local development environment for contributing to scikit-SUNDAE. It covers recommended practices, tools, and commands for developers to efficiently build, test, and contribute to the project.
Note
We assume developers are already at least a little familiar with using git and GitHub. If this is not the case for you, there are many online tutorials to help you learn git.
- Fork and clone the repository
Before setting up your local environment, make sure you have forked the main repository and cloned it from your own fork. This allows you to create pull requests from your fork to the main repo.
- Install a C compiler
If you are using the Windows operating system, we recommend Visual Studio, but if you have another preferred compiler that should work too. For MacOS and other Linux-based operating systems, we recommend Clang, which can be installed through the terminal using:
xcode-select --install (for MacOS) sudo apt install clang (for Linux)
- Create a virtual environment
Since we build scikit-SUNDAE agasint SUNDIALS releases on conda-forge, you will need to set up a virtual environment with
condaaccess. While there are a few options you can use, we recommend using Anaconda. With Anaconda installed, open the terminal (MacOS/Linux) or Anaconda Prompt and run:conda create -n sun -c conda-forge python=x.x sundials=x.xThe
x.xversion numbers should be filled in with the latest stable releases of Python and SUNDIALS. Continuous Integration (CI) workflows automatically test older Python versions.On occasion, you may need to work with older Python and/or SUNDIALS versions (e.g., patching old versions, or resolving version-specific CI failures). In cases where you are not working with the latest version of scikit-SUNDAE, please reference the table on the main Installation page to verify SUNDIALS compatibilities.
- Set the
SUNDIALS_PREFIXenvironment variable scikit-SUNDAE expects your SUNDIALS installation to be in either
$CONDA_PREFIXor%CONDA_PREFIX%Library. Check to see if your installation is in either of these directories. If it isn’t, you will need to set theSUNDIALS_PREFIXenvironment variable:set SUNDIALS_PREFIX="..." (on Windows) export SUNDIALS_PREFIX="..." (on MacOS or Linux)
If you used Anaconda to setup your environment you can likely skip this step, but it is good practice to double check that SUNDIALS was installed in one of the expected directories.
- Set the
- Install scikit-SUNDAE in editable mode
Once you have your virtual environment activated and the files locally available, install scikit-SUNDAE in editable mode, including the necessary development tools and dependencies, like so:
pip install -e .[dev]Make sure you are in the same folder as the
pyproject.tomlfile when you run this command.The
-eflag ensures that any changes to local Python files will be immediately available without reinstalling. However, modifying Cython files (.pyxor.pxd) will require rebuilding, as covered in the Version Control section.The
[dev]argument installs all developer dependencies: linters, spellcheckers, testing tools, and more.
- Running tests
We recommend testing your installation before you start making changes. To run unit tests and make a coverage report, we have integrated
nox:nox -s testsThis will run all tests and generate coverage reports. You can see the coverage report by opening the
index.htmlfile in thereports/htmlcov/folder once the tests are finished.
- Linting, formatting, and spellchecking
All linting, formatting, and spellchecking tasks are automated. To run these checks locally:
nox -s linter [-- format] nox -s codespell [-- write]
The optional
formatandwritearguments will attempt to format the code and correct misspellings, respectively. For more information on linting and code style, make sure you reference the Code Style and Linting section.
- Building documentation
We use sphinx to build documentation by scraping docstrings. Before you start modifying the code base, make sure the documentation builds locally:
nox -s docsYou can see the local documentation build in your browser by opening the
index.htmlfile from thedocs/build/folder, after running the command above.
Now that you’re all setup with a development version of scikit-SUNDAE and have tested the codebase using the nox integration, be sure to follow the Version Control workflow as you contribute. Happy coding!