-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Allow running a session with a different Python interpreter #623
Comments
I'm personally open to this idea, but I would also like to hear the opinion from other maintainers. If we decide to apply this, I'm a strong +1 to add |
Hi @pfmoore!
If you use
You should be able to do e.g
I'm with you on this one, there is a proposal in #384 to read Overall I like this idea, my only cause for concern is the presence of both a I would like it if we could combine the functionality into 1 flag but if that's not feasible or leads to too much mess I'm happy with the Perhaps the |
I'm aware of that but (a) it's more verbose, and (b) it requires me to parametrise the session, which as I say is a maintenance overhead.
That would still result in the session being parametrised, which means that Just a thought, though - as far as reading
Fair point. I couldn't see the point of Actually, I just did some further testing. If I put the following in my import nox
@nox.session(python=[None])
def test(session):
session.run("python", "-V") it appears to work just as I want: I don't understand the difference between In the meantime I have a workaround. It's ugly, but it appears to give me the behaviour I want. |
This looks like a good approach to me :)
According to https://nox.thea.codes/en/stable/config.html#defining-sessions, |
Sorry, I should have been clearer, I knew that (that's actually what prompted me to try |
Oh, got it. I'm also not sure of that 🤷♂️ |
Oh I see now sorry! You want to have a session e.g.: @nox.session
def test(session):
session.install("pytest")
session.run("pytest") That will by default run on the python that Nox is installed into, and then you want to instruct it to use another one i.e.:
The session will now run on 3.9 (if available)? In this case I think your suggestion is the cleanest way to implement this:
|
@FollowTheProcess Exactly that, yes. |
I am interested in this behaviour and will work on implementing it shortly. |
How would this feature be useful?
I normally run
nox -s test
to run my tests using the default Python version (the one nox is installed under, I guess?) This is my most common activity, and I'd like it to be straightforward. However, I sometimes want to run the tests for a specific Python version. I can do this by parametrising the Python version for the test session, but if I do that,nox -s test
now means "run the test session for all Python versions.Furthermore, I don't want to have to hard-code the list of Python versions. Doing that means I need to update the noxfile every time a new Python version comes out.
Describe the solution you'd like
If a session does not have the Python version parametrised,
nox -s session --use-python 3.9
would run the given session with Python 3.9. Having-P
as a short form for--use-python
would be useful.Describe alternatives you've considered
@session(python=None, "3.8", "3.9", "3.10")
looks like it might work, as it creates a session with no suffix. But that still runs all of the suffixed sessions, rather than just running the one session.--force-pythons
sounds like it would work, but it doesn't, it just says "Python version selection caused no sessions to be selected".Anything else?
No response
The text was updated successfully, but these errors were encountered: