Skip to content

Local build

We use a combination of conda and poetry. Each on its own is more than enough; however, we often want to use packages that are only available in conda. Mixing environment manages like conda and poetry must be done with care. This usually involves install all desired conda packages and then using only poetry afterwards. If you want to use a new conda package down the road, you normally need to recreate the environment from scratch.

Steps

Installing conda

If you do not have conda installed, follow the instructions here.

Note

We recommend using libmamba instead of mamba or classic conda.

Conda environment

First, we setup a conda environment inside the repository (.venv).

make conda-setup

Now we install our desired conda packages in one of two ways.

This will install the exact same packages we use to develop this package.

make from-conda-lock

With this procedure, you can install any conda packages desired. First, activate the conda environment.

conda activate ./.venv

Add all relevant conda channels so they are exported to environment.yml. For example, we can add conda-forge.

conda config --add channels conda-forge

Install all desired packages; for example,

conda install -c conda-forge mkdocs

If needed, write a new conda-lock file.

make write-conda-lock

Poetry-tracked packages

After installing all conda packages, we switch over to exclusively using poetry. The following command uses poetry to install all packages specified in pyproject.toml.

make install

Add packages

To add dependencies using the poetry add command, you need to first activate the conda environment.

conda activate ./.venv

Now you can run any poetry commands within the local conda environment. For example, we can add numpy as a dependency:

poetry add numpy

After making any changes to pyproject.toml you need to write a new poetry.lock file.

make lock-poetry

Remember to deactivate the conda environment once you are done.

conda deactivate

pre-commit

TODO:

make pre-commit-install