Our codes often depend on other codes that in turn depend on other codes …
These tools try to solve the following problems:
Compare these four requirements.txt
solutions:
A:
Code depends on a number of packages but there is no requirements.txt
file or equivalent.
B:
scipy
numpy
sympy
click
git+https://github.com/someuser/someproject.git@master
git+https://github.com/anotheruser/anotherproject.git@master
C:
scipy==1.3.1
numpy==1.16.4
sympy==1.4
click==7.0
git+https://github.com/someuser/someproject.git@d7b2c7e
git+https://github.com/anotheruser/anotherproject.git@sometag
D:
scipy==1.3.1
numpy==1.16.4
sympy==1.4
click==7.0
someproject==1.2.3
anotherproject==2.3.4
$ pip install somepackage
$ pip install somepackage==1.2.3
requirements.txt
:
$ pip freeze > requirements.txt
requirements.txt
:
$ pip install -r requirements.txt
$ pip install git+https://github.com/anotheruser/anotherproject.git@sometag
$ conda install somepackage
$ conda install somepackage=1.2.3
$ conda create --name myenvironment
requirements.txt
:
$ conda create --name myenvironment --file requirements.txt
$ conda activate myenvironment
$ conda deactivate
$ conda info -e
requirements.txt
:
$ conda list --export > requirements.txt
environment.yml
:
$ conda env export > environment.yml
Conda packages can be built from a recipe and shared on anaconda.org via your own private or public channel, or via conda-forge.
A step-by-step guide on how to contribute packages can be found in the conda-forge documentation.
To get an idea of what’s needed, let’s have a look at the boost feedstock (a set of C++ libraries). We see that:
recipe/
directory, along with (optional) build.sh
and bld.bat
files for building
non-python code on OSX/Linux and Windows platforms.$ virtualenv myenvironment
$ virtualenv --python=python3 myenvironment
$ virtualenv /path/to/myenvironment
$ source myenvironment/bin/activate
$ pip install somepackage
$ deactivate
Pipenv
and Pipenv.lock
Capturing software dependencies is a must for reproducibility.
Files like requirements.txt
, environment.yml
, Pipenv
, …, should be part of the source repository.
Be skeptical when you see dependency lists without versions.