Musings with Rust and Python with PyO3
There currently is some redundancy when it comes to specifying dependencies. This originates from a number of factors:
- Rust and Python have different ways of managing dependencies.
- I use Nix to ensure I have reproducible development environments. This clashes massively with Python dependency management.
- We also want to make this usable when Conda orchestrates the Python environment.
Cargo.toml
. This specifies the Rust dependencies: first and foremost PyO3. TODO: Maybe specify non-dev Python deps here?pyproject.toml
. This specifies that the build system for the Python project is maturin. In the future we might include more stuff here, depending on which packaging/environment manager tool takes hold in the Python world.Pipfile
. This is used to set up the Python environment correctly. TODO Should this list all deps (non-dev + dev)?environment.yml
. Same asPipfile
, but for Conda.
In addition:
shell.nix
This specifies the Nix shell to create..envrc
Automates the whole thing.
In a real-world repository shell.nix
and .envrc
would not be checked in,
but rather tracked in a "stash branch" using git-along
pipenv install --dev .
installs the project and its development dependencies.
This is an editable install and puts the scripts (entry points) in the right
places.
maturin develop
builds the Rust extension. Needs to be done to actually get
python -c "import rustafarian"
to work without problem from the root of the
project.
I guess if one has tests for the scripts pipenv install --dev
and maturin develop
might be enough?
Copyright (c) 2018, Charles J. C. Scott, Roberto Di Remigio Licensed under MPL v2.0.