-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Using Poetry with Nox #2920
Comments
see also #1745 |
cross-posted to wntrblm/nox#347 |
I ran into the same problem this afternoon, decided to just use tmp directories so that I could modify and discard the repo repeatedly: from distutils.dir_util import copy_tree
import os
import pathlib
import shutil
import tempfile
import nox
@nox.session(python=["3.8", "3.7", "3.6"])
@nox.parametrize("numpy", ["1.19.2", "^1.18.4", "^1.17.5"])
@nox.parametrize("pillow", ["7.0.0", "^6.0.0", "^5.4.0"])
def tests(session, numpy, pillow):
with tempfile.TemporaryDirectory() as tmp_dir:
base_dir = pathlib.Path(os.path.abspath("."))
copy_tree(base_dir, tmp_dir)
os.chdir(tmp_dir)
args = session.posargs or ["--cov=flywheel"]
session.run('poetry', 'add', f"numpy@{numpy}", f"pillow@{pillow}", external=True)
session.run("poetry", "install", external=True)
session.run("pytest", *args) |
@max-hoffman that's a neat solution. I was considering just caching and replacing the |
@sdispater, the Nox maintainers have reached out and I suspect would be keen to investigate a tighter integration between Poetry and Nox. Is this something you'd be interested in looking into? |
@danieleades a try/except/finally block where the original |
@max-hoffman the i've got
try as I might, I can't get that |
i was doing something like this and decided to throw in a |
You could do something like this: from shutils import copytree
import nox
@nox.session(python=["3.8", "3.7", "3.6"])
@nox.parametrize("numpy", ["1.19.2", "^1.18.4", "^1.17.5"])
@nox.parametrize("pillow", ["7.0.0", "^6.0.0", "^5.4.0"])
def tests(session, numpy, pillow):
tmp_dir = session.create_tmp()
copytree(base_dir, tmp_dir)
session.install("poetry")
session.run("poetry", "add", f"numpy@{numpy}", f"pillow@{pillow}")
session.run("poetry", "install")
args = session.posargs or ["--cov=flywheel"]
session.run("pytest", *args) The issue with this is that it introduces all of Poetry's dependencies in the test session's virtual env. |
You could also use nox-poetry which exports a requirements file with Poetry and defers to pip for installing packages. |
We should all thank @cjolowicz for this cookiecutter template taht implements nox-poetry: https://cookiecutter-hypermodern-python.readthedocs.io/en/2020.10.15.1/ He also wrote nox-poetry plugin |
Poetry team can't and won't keep track of all the tools that are used and without it, maintenance of such documentation would be impossible. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue
I've been trying to migrate an existing project to Poetry. It is using
Tox
to test a matrix of different package versions. The difficulties of trying to get Poetry and Tox to play nicely together for matrices of package versions is fairly well-documented (see https://stackoverflow.com/questions/59377071/how-can-i-get-tox-and-poetry-to-work-together-to-support-testing-multiple-versio)I'm playing around with Nox as an alternative, and it's looking very promising for being easier to integrate with Poetry, but there are still a few caveats.
I have the following Nox script for testing against a couple of different python interpreters, and a couple of different versions of sphinx-
this works perfectly, except that it modifies the
pyproject.toml
file in my project's root. Is there a better way for me to arrange this?The text was updated successfully, but these errors were encountered: