How to run tox and poetry together against multiple dependency versions
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Issue
I have a question around the use of poetry
and tox
, when testing a library against a matrix of supported dependencies. My current example is a Django app, which I would like to test against Django 2.2. and 3.0. The tox.ini
config is as below (taken from the docs - https://python-poetry.org/docs/faq/#is-tox-supported):
[tox]
envlist = py{36,37,38}-django{22,30}
[testenv]
deps =
django22: Django==2.2
django30: Django==3.0
whitelist_externals = poetry
skip_install = true
commands =
poetry install -vvv
poetry run django-admin --version
poetry run pytest tests/
My pyproject.toml
file lists the Django dependency as:
[tool.poetry.dependencies]
python = "^3.6"
django = "^2.2 || ^3.0"
When running tox, the version number output for all test runs is 3.0. It looks like the lock file is created on the first test run, and then re-used for the rest, and that the lock file is always the latest version of Django (3.0), even when 2.2 is already installed.
I’m a bit stuck at this point, as without being able to test against a matrix of versions I can’t progress. Any help gratefully received. (I am also happy to add a docs PR once I’ve worked out the solution, as I can’t be the only person with this issue?)
Update: adding output from a test run that shows a.) Django 2.2 being installed by tox, and then b.) poetry overwriting it.
my-app$ tox -r -e py36-django22
py36-django22 recreate: .tox/py36-django22
py36-django22 installdeps: Django==2.2
py36-django22 installed: Django==2.2,my-app==0.1.0,pytz==2019.3,sqlparse==0.3.0
py36-django22 run-test: commands[0] | poetry install -vvv
Using virtualenv: .tox/py36-django22
Updating dependencies
Resolving dependencies...
1: derived: django (^2.2 || ^3.0)
...
PyPI: 10 packages found for django >=2.2,<4.0
...
1: Version solving took 3.330 seconds.
1: Tried 1 solutions.
Writing lock file
Package operations: 52 installs, 1 update, 0 removals, 3 skipped
- ...
- Updating django (2.2 -> 3.0)
- ...
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:14 (1 by maintainers)
Top GitHub Comments
I think a good course of action, would be for people here (i.e. people who have experience with tox and poetry), to make some clear condensed suggestion of what they would like to see in the documentation/FAQ.
Someone already made a pull request: https://github.com/python-poetry/poetry/pull/2416
Maybe people should go have a look at it, comment on it, make suggestions, etc.
I published on PyPI a plugin for Tox to instruct it to install Poetry’s development dependencies in the test environments: tox-poetry-dev-dependencies. It’s just a proof of concept. I didn’t test much, only with a very simple project.