Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zzzeek
Copy link
Contributor

@zzzeek zzzeek commented Sep 27, 2025

in the case where nox is run given an explicit python version target to run on, nox locates Python interpreters by matching that interpreter string to a regex, that is then expanded to match the name of a Python executable by appending the numeric portions of the version to the word "python", its existence is verified with
shutil.which(), and is then passed off to virtualenv as a target to use.

However, if the explicit python version ends in "t" for a free-threaded python, such as "3.13t", the regex does not match, due to that "t" that's present which isn't included in the regex.

This PR fixes the regex to also look for a "t" at the end for a free-threaded version name, and formats it into the interpreter name virtualenv will look for.

There's a bit of a secondary issue which is that if you are trying to select for "3.13" non-free-threaded, but you have a free-threaded 3.13t in your path as well, that "python3.13" name matches in the free-threaded bin folder as well, but virtualenv seems to know how to make the right choice in this case.

The only issue I could find regarding free-threading is #949 which vaguely claims that free-threading is working, however this patch is needed if you actually want to indicate the Python version.

Fixes: #949

in the case where nox is run given an explicit python version
target to run on, nox locates Python interpreters by matching
that interpreter string to a regex, that is then expanded
to match the name of a Python executable by appending the
numeric portions of the version to the word "python", its
existence is verified with
shutil.which(), and is then passed off to virtualenv as a target
to use.

However, if the explicit python version ends in "t" for a free-threaded
python, such as "3.13t", the regex does not match, due to that
"t" that's present which isn't included in the regex.

This PR fixes the regex to also look for a "t" at the end for
a free-threaded version name, and formats it into the interpreter
name virtualenv will look for.

There's a bit of a secondary issue which is that if you are trying
to select for "3.13" non-free-threaded, but you have a free-threaded
3.13t in your path as well, that "python3.13" name matches in the
free-threaded bin folder as well, but virtualenv seems to know how
to make the right choice in this case.

The only issue I could find regarding free-threading is wntrblm#949 which
vaguely claims that free-threading is working, however this
patch is needed if you actually want to indicate the Python version.

Fixes: wntrblm#949
@zzzeek
Copy link
Contributor Author

zzzeek commented Sep 27, 2025

TIL I can also send the full executable name like python3.13t in, and that bypasses the regex issue here, but this still would be a good fix to have

@zzzeek
Copy link
Contributor Author

zzzeek commented Sep 30, 2025

ah it fails when we use pytest-xdist and run in separate processes.

Copy link
Collaborator

@henryiii henryiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of #949, I think.

@henryiii henryiii merged commit c804a04 into wntrblm:main Oct 8, 2025
21 checks passed
@ngoldbaum
Copy link

Thank you for fixing this!

I had only used nox with projects that don't use any of the python environment setup features and just pip install nox into a single Python environment. So I never ran into the problems solved here.

sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this pull request Oct 18, 2025
the workaround for [1] no longer works now that the fix has
been committed.  slightly surprising but just require that version
of nox and carry on

[1] wntrblm/nox#999

Change-Id: I4b4031c3d3d02399f55f9750237de61e5e90d179
sqlalchemy-bot pushed a commit to sqlalchemy/alembic that referenced this pull request Oct 18, 2025
includes fix for  wntrblm/nox#999

Change-Id: Id38dc01a1fb8a7446e427a8cf9a0cae2db6c4a3b
sqlalchemy-bot pushed a commit to sqlalchemy/dogpile.cache that referenced this pull request Oct 18, 2025
includes fix for  wntrblm/nox#999

Change-Id: Id38dc01a1fb8a7446e427a8cf9a0cae2db6c4a3b
sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this pull request Oct 21, 2025
the workaround for [1] no longer works now that the fix has
been committed.  slightly surprising but just require that version
of nox and carry on

[1] wntrblm/nox#999

Change-Id: I4b4031c3d3d02399f55f9750237de61e5e90d179
(cherry picked from commit e1f3b43)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Document support for the free-threaded build and add to tests

3 participants