How to run tox and poetry together against multiple dependency versions #4307
Replies: 14 comments 6 replies
-
Cross-posted to StackOverflow - https://stackoverflow.com/q/59377071/45698 |
Beta Was this translation helpful? Give feedback.
-
Same issue, I'm to test against django 1.11 up to 3.0. But poetry always override the specified deps. One way to solve this would be to allow specifying a version to poetry install as long as it doesn't collide with the poetry.toml |
Beta Was this translation helpful? Give feedback.
-
I made a suggestion to hopefully solve this kind of issues on the StackOverflow question as well as on the issue #1941. Since tox already takes care of installing the project and its dependencies in virtual environments, there is no need to get poetry involved. Except to build the sdist, which is exactly what So it could look like the following, note how the extra
On the other hand, the drawback is that to get the development dependencies in the normal poetry virtual environment an extra call to |
Beta Was this translation helpful? Give feedback.
-
I got around this issue by exporting all dependencies, removing Django, and then using pip to install them:
There may be a nicer way to run commands with pipe in tox.ini other than |
Beta Was this translation helpful? Give feedback.
-
Would you mind expanding on the advantages of your solution? Anyway... Unless I am missing something, I believe this could probably be simplified:
Maybe something like that:
Probably the bash part can be simplified as well. |
Beta Was this translation helpful? Give feedback.
-
@sinoroc the main advantage is no need to change pyproject.toml. This is a work-around for those that don't want to maintain an "extras" part of pyproject.toml just for testing requirements, not to mention having to do And yea, there are likely some ways to make the original code nicer. I just posted what was working for me after hacking around at it. You can also condense it more if you want to avoid storing a ".requirements.txt" file:
I leave |
Beta Was this translation helpful? Give feedback.
-
I see, but at this point, we are skipping so many of the advantages of tox, it might be worth questioning why use it at all. Oh by the way, you might want to add But sure, no discussion about it, each project has its own specific needs that call for its own specific workflow. It's good we have the flexibility to adapt to each needs. To me, the key element that pops out of this discussion, is that there is no straightforward way for tox to get the list of dev dependencies from poetry. And that is what is preventing a clean integration between these two tools. |
Beta Was this translation helpful? Give feedback.
-
@sinoroc my suggestion is for people that don't want to use the previous suggestions. It doesn't skip many advantages of tox and is not that different than the original solutions. One could also say that the problem is also that poetry does not allow one to override dependencies in a There's been quite a bit of noise since my previous suggestion. So, if you are coming to this thread and want a way to use tox in a poetry project without hacking your pyproject.toml, you can do this:
|
Beta Was this translation helpful? Give feedback.
-
@wesleykendall So, if I want my pyproject.toml and tox.ini as generic as possible, there is no way to avoid specifying the dev dependencies twice? Proposed way forward: Ask the tox dev's to include an option such that tox also installs the pyproject.toml dev dependencies? |
Beta Was this translation helpful? Give feedback.
-
@wesleykendall Your solution is the most elegant one I've seen so far IMHO. Here's how I would strive for tighter uncoupling right now:
@webartifex The above tweak should address your issue since it no longer requires poetry when cloning/testing the package. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Edit: I've been using It would be helpful if there was some official docs at https://python-poetry.org/docs/faq/#is-tox-supported had some discussion about the issues around So far, the best solution I've found that doesn't break |
Beta Was this translation helpful? Give feedback.
-
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: #2416 Maybe people should go have a look at it, comment on it, make suggestions, etc. |
Beta Was this translation helpful? Give feedback.
-
Belatedly, thank you @sinoroc, your package takes care of this need very nicely! 🙏🏻 |
Beta Was this translation helpful? Give feedback.
-
Issue
I have a question around the use of
poetry
andtox
, 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. Thetox.ini
config is as below (taken from the docs - https://python-poetry.org/docs/faq/#is-tox-supported):My
pyproject.toml
file lists the Django dependency as: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.
Beta Was this translation helpful? Give feedback.
All reactions