hypermodern-python icon indicating copy to clipboard operation
hypermodern-python copied to clipboard

test session remove and install dependencies at each call

Open oncleben31 opened this issue 5 years ago • 2 comments

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
...

oncleben31 avatar Jun 23 '20 21:06 oncleben31

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

cjolowicz avatar Jun 24 '20 07:06 cjolowicz

Indeed the new approach in the cookiecutter template is better. Thank you. The blog post will need an update.

oncleben31 avatar Oct 22 '20 07:10 oncleben31