Skip to content

Allow running a session with a different Python interpreter #623

@pfmoore

Description

@pfmoore

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

  • Using @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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions