-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run tox and poetry together against multiple dependency versions #1745
Comments
Cross-posted to StackOverflow - https://stackoverflow.com/q/59377071/45698 |
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 |
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 |
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 |
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. |
@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 |
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. |
@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:
|
@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? |
@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. |
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. |
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 |
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. |
Belatedly, thank you @sinoroc, your package takes care of this need very nicely! 🙏🏻 |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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.
The text was updated successfully, but these errors were encountered: