Nix is a language-agnostic package manager that installs packages locally. Nix Flakes are a way of specifying dependencies to Nix declaraively. Currently, they are installed separately.
nix develop
to get a shell.nix develop --command ipython
to run a command, such asipython
, in the project's environment.
In addition to Nix, I suggest also installing direnv and nix-direnv. Then simply cd
ing to the project will activate the project-specific environment.
cd /path/to/project
to get a shell.nix develop --command ipython
to run a command, such asipython
, in the project's environment.
Consider adding this line in your shell's initfile so you can see when direnv
is activated. PS1="\$PREPEND_TO_PS1$PS1"
Note that the sigil (dollar sign) in $PREPEND_TO_PS1
is quoted but the one in $PS1
is not, so PS1
is evaluated when the shell initializes, but PREPEND_TO_PS1
is evaluated before every prompt.
Nix can be trouble to set up, so here is how to use the project without Nix. Poetry is a wrapper around pip
/virtualenv
, and it will manage dependencies from PyPI, but you have to manage external dependencies, e.g. installing the right version of Python, C libraries, etc. Poetry can be installed globally with python -m pip install poetry
.
poetry shell
to get a shell.poetry run ipython
to run a command, such asipython
, in the project's environment.
Once in the development environment, use ./script.py
to run development tools. In the order of usefulness,
-
./script.py fmt
runs code formatters (autoimport, isort, black). -
./script.py test
runs tests and code complexity analysis (mypy, pylint, pytest, [coverage.py][coverage], radon in parallel). -
./script.py all-tests
runs the usual tests and more (proselint, rstcheck, twine, tox (which runs mypy and pytest in each env)). This is intended for CI. -
./script.py docs
builds the documentation locally (proselint). -
./script.py publish
publishes the package to PyPI and deploys the documentation to GitHub pages (./scripts.py all-tests
, bump2version, poetry publish, git push).