hypermodern-python
hypermodern-python copied to clipboard
test session remove and install dependencies at each call
In the chapter Managing dependencies in Nox sessions with Poetry you explain how we can use poetry to pin the development dependencies and avoid installing some according to the type of test session.
The result is each time I launch now -rs test first poetry uninstall dependencies that pip will re-install just after. It doesn't seem optimal.
Log:
nox > Running session tests-3.7
nox > Re-using existing virtual environment at .nox/tests-3-7.
nox > poetry install --no-dev
Installing dependencies from lock file
Package operations: 0 installs, 0 updates, 14 removals
- Removing coverage (5.1)
- Removing importlib-metadata (1.6.1)
- Removing more-itertools (8.4.0)
- Removing packaging (20.4)
- Removing pluggy (0.13.1)
- Removing py (1.8.2)
- Removing pyparsing (2.4.7)
- Removing pytest (5.4.3)
- Removing pytest-cov (2.10.0)
- Removing pytest-mock (3.1.1)
- Removing six (1.15.0)
- Removing toml (0.10.1)
- Removing wcwidth (0.2.4)
- Removing zipp (3.1.0)
- Installing hypermodern-python (0.1.0)
nox > poetry export --dev --format=requirements.txt --output=/var/folders/v5/wtydb2rx72b74xds_1hc2xr80000gq/T/tmp2tb8qu3a
nox > pip install --constraint=/var/folders/v5/wtydb2rx72b74xds_1hc2xr80000gq/T/tmp2tb8qu3a coverage[toml] pytest pytest-cov pytest-mock
nox > pytest --cov -m not e2e
...
Yes, this is a known limitation. There is a better technique for installing the package into Nox sessions, that does not have this issue: Pip-install the core dependencies using poetry export, then build and install a wheel from your package. Take a look at the Hypermodern Python Cookiecutter for how to do this.
Related:
- https://github.com/cjolowicz/cookiecutter-hypermodern-python/issues/348
- https://github.com/cjolowicz/cookiecutter-hypermodern-python/issues/3
- https://github.com/cjolowicz/cookiecutter-hypermodern-python/pull/23
- https://github.com/cjolowicz/blog/issues/4
Indeed the new approach in the cookiecutter template is better. Thank you. The blog post will need an update.