-
-
Notifications
You must be signed in to change notification settings - Fork 158
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 Nox with Poetry #347
Comments
How does it modify the file?
…On Tue, Sep 15, 2020 at 12:25 PM danieleades ***@***.***> wrote:
cross-posted to python-poetry/poetry#2920
<python-poetry/poetry#2920>
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 <https://nox.thea.codes/en/stable/index.html>
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-
import nox
@nox.session(python = ["3.5", "3.6"]
@nox.parametrize("sphinx", ["^2.4", "^3.0"])def tests(session, sphinx)
session.run('poetry', 'add', f'sphinx@{sphinx}', external=True)
session.run('poetry', 'install', external=True)
session.run('pytest')
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?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#347>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I467I3V4VCLT65CNH7TSF6IPFANCNFSM4RNMOOZQ>
.
|
the for example if sphinx version is set to |
To be clear, I'm not suggesting that nox is misbehaving! |
We're definitely happy to support poetry use cases, I'm just not personally
familiar enough to know. Maybe we can get one of the poetry maintainers on
this thread to help out?
…On Tue, Sep 15, 2020 at 4:31 PM danieleades ***@***.***> wrote:
To be clear, I'm *not* suggesting that nox is misbehaving!
Im simply wondering if this workflow can be supported today, or if there
is interest in implementing it (either on the nox side, or the Poetry side)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#347 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I4ZIHJ7TB54ZA2TBZITSF7FKFANCNFSM4RNMOOZQ>
.
|
there are a couple of solutions proposed in python-poetry/poetry#2920 I wonder what a first class API would look like?
|
@theacodes you can see the approach i'm attempting to use to restore the it's not working because wrapping nox in a Is there anyway to cleanup code after a session with Nox? Effectively a 'teardown' function |
Sure it works - @nox.session(python=python_versions)
@nox.parametrize("sphinx", sphinx_versions)
def tests(session, sphinx):
try:
session.run('poetry', 'add', f'sphinx@{sphinx}', external=True)
session.run('poetry', 'install', external=True)
session.run('nosetests')
finally:
dump(project_file)
dump(lockfile) |
i'm afraid this still isn't working given this code- import nox
@nox.session(python = ["3.5", "3.6"]
@nox.parametrize("sphinx", ["^2.4", "^3.0"])
def tests(session, sphinx)
session.run('poetry', 'add', f'sphinx@{sphinx}', external=True)
session.run('poetry', 'install', external=True)
session.run('pytest') the python interpreter used is always the one selected by Poetry, in my case 3.8. |
Yes, you should install Poetry and pytest with Nox. |
Hi @danieleades would something like this work for you? import nox
@nox.session(python=["3.5", "3.6"])
@nox.parametrize("sphinx", ["2.4.4", "3.2.1"])
def tests(session, sphinx):
session.install(".", f"sphinx=={sphinx}", "pytest")
session.run("pytest") This will install and test your package with a specific sphinx version, using only the version constraints in the package metadata, not the lock file. |
I did get this working in the end! With the original solution. I suspect it was working all along ... |
Is this still a bug? Should I keep this open? It doesn't seem like there's anything left to resolve here, so I'm going to close for now but I'm happy to re-open if there's still more work to do. |
if anyone stumbles upon this, I've got a working implementation, integrated with a github action here - https://github.com/danieleades/sphinxcontrib-needs/actions |
cross-posted to python-poetry/poetry#2920
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: