This repository uses pixi to manage the environment through the pyproject.toml file.
Note that installing a pixi environment will automatically install the dem-handler project in editable mode.
Using pixi is beneficial as it allows us to store named requirements in the pyproject.toml file, and provides a pixi.lock file that captures specific versions whenever the pixi environment is solved/installed.
Follow the pixi installation guide.
Environments are associated with the project.
- The
defaultenvironment contains packages required for the code base (e.g. gdal, rasterio). - The
devenvironment contains everything from thedefaultenvironment, PLUS packages required for tests (e.g. pytest).
cd to the repository folder and install the environments:
To install both environments, run
pixi install --allFor development, we use pre-commit to run linting with black, as well as some extra tasks to ensure the pixi.lock file and environment.yaml files are up-to-date.
As a one-time action, run
pixi run -e dev pre-commit install
Pixi supports tasks (similar to using a Makefile) which can help automate common actions. In the repo, we have the following tasks, associated with the dev environment:
download_test_data, which will download test data from AWStest, which depends ondownload_test_dataand will then runpytest
To run tests, use
pixi run testFor the default environment, use
pixi run <command>For the dev environment, use
pixi run -e dev <command>For longer sessions, you can activate the environment by running
pixi shellor
pixi shell -e devTo exit the shell, run
exitIf wanting to install from conda-forge, use
pixi add <conda-forge-package>If wanting to install from pypi, use
pixi add --pypi <pypi-package>
When a new package, consider whether it is required to run the code, or to do development/run tests.
If needed for development, add it to the dev environment:
pixi add --feature dev --pypi <pypi-package>