The main resource is Anna-Lena Popkes’ post An unbiased evaluation of environment management and packaging tools. See also Modern good practices for python development.
python virtual environments
pyenv
is a python version management tool, which makes it easy to switch between multiple versions of Python. It works alongside a virtual environment manager venv
(or virtualenv
) and a package installer pip
. The uv
project aims to replace all of these.
conda
is its own distribution of python (and R), and contains the python version and packages all in one, as well as dealing with package management. It is commonplace in scientific computing.
uv
Replacing pyenv + venv + pip
mamba (conda, but quick)
This worked for me for a long time. I tried to move to micromamba, which does not have a base environment, but VSCode would not let me select micromamba environments as the python interpreter.
Time to try out pixi
project, which is built by the mamba devs. It aims to overcome many of the issues whilst also being a multi-language package manager. You will be able to build pip
and conda
packages using pixi
. It has VSCode support.
python package management
Everything should get a python package. We should constantly be refactoring model development notebooks into .py
files.
However, python packaging is was a mess. Now uv
will sort everything out.
I am periodically trying different tools (listed on PyPA) using the latest practices. Use a pyproject.toml
, not setup.py
.
Below are some working notes:
package | comments | example repo |
---|---|---|
setuptools | Default | |
hatch | Not bad, although need to enter dependencies manually (unless using uv ). | tinygp |
flit | Why aren’t more people using this? Hardly any projects are not pure python. This simplifies things massively. | bayeux |
poetry | I’ve used it a lot. It’s easy but it’s kind of slow… to resolve dependencies. | GPJax |
pdm | Not yet used | |
uv | drop in replacement for pip (and soon everything else). rapid | uv |
standalone scripts
We can declare the dependencies for a script in the script itself via uv
.