Skip to content

Support CPython+t in ICs to select free-threaded CPython.#3067

Merged
jsirois merged 5 commits intopex-tool:mainfrom
jsirois:IC/add-marker-form
Jan 12, 2026
Merged

Support CPython+t in ICs to select free-threaded CPython.#3067
jsirois merged 5 commits intopex-tool:mainfrom
jsirois:IC/add-marker-form

Conversation

@jsirois
Copy link
Copy Markdown
Member

@jsirois jsirois commented Jan 10, 2026

No description provided.

@jsirois jsirois requested a review from sureshjoshi January 10, 2026 03:32
'e.g. "CPython>=2.7,<3" (A CPython interpreter with version >=2.7 AND version <3), '
'">=2.7,<3" (Any Python interpreter with version >=2.7 AND version <3) or "PyPy" (A '
"PyPy interpreter of any version). This argument may be repeated multiple times to OR "
"PyPy interpreter of any version). The recognized requirement names are `CPython` for "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just confirming my understanding re: tests and re: release notes against this help message.

The CPython name captures classic + free-threaded, while CPython_t is strictly free-threaded?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you intend to add a mechanism to deterministically enforce non-free-threaded builds? Similar to uv’s +gil idea: https://docs.astral.sh/uv/concepts/python-versions/#free-threaded-python

Or do you think that that be better handled at a higher level (e.g. Pants providing an option to limit to gil-builds).

Copy link
Copy Markdown
Member Author

@jsirois jsirois Jan 10, 2026

Choose a reason for hiding this comment

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

I did not intend to, no. But I'll do so, instead just allowing selection on abiflags. So, CPython maintains the current meaning of any CPython, and CPython+t means CPythons with the t abi flag (free-threaded), and CPython+t-d means CPythons that are free-threaded but are not debug builds, etc. Basically same level of complexity in the code support but cut these questions off at the pass.

Or do you think that that be better handled at a higher level (e.g. Pants providing an option to limit to gil-builds).

You have no way to do this at a higher layer unless you stop using Pex for interpreter discovery or you do something super complex like probe pythons on the PEX_PYTHON_PATH / --python-path you set up and arrange the ordering of said PEX_PYTHON_PATH / --python-path to ensure earliest on the search path satisfies the users needs. At that point though, you're doing interpreter discovery yourself basically; so this would seem tortured.

Basically, I'm super confused why you'd suggest this.

Copy link
Copy Markdown
Member Author

@jsirois jsirois Jan 10, 2026

Choose a reason for hiding this comment

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

Ok, I'm shelving the full abiflags handling. It's both more complicated than I imagined and I don't truly grok the landscape over time; so I'll punt but stick with the syntax. There will now be exactly 4 implementations:

  • CPython: Any CPython implementation (as is today).
  • CPython+t: Only CPythons built with free-threading support.
  • CPython-t: Only traditional GIL enabled CPythons (i.e.: CPythons built without free-threading support or 3.12 or older CPythons where there was no such support at all).
  • PyPy: Any PyPy implementation (as is today).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At that point though, you're doing interpreter discovery yourself basically; so this would seem tortured.

I agree.

Basically, I'm super confused why you'd suggest this.

The ability to select any python, and strictly free-threaded, but no ability to strictly select no-gil seemed like an obvious gap - I assumed it was intentional, that’s all.

Copy link
Copy Markdown
Member Author

@jsirois jsirois Jan 10, 2026

Choose a reason for hiding this comment

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

It was intentional in the strategy of implement what is asked for and no more as long as it doesn't close off avenues - let someone complain to fill in the gap later.

No one asked for GIL-only, so I was defaulting to not supporting that yet. You then asked, and you 1/2 count (I assume you don't actually need this but are anticipating an actual user need); so adding it now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Alright @sureshjoshi, this is ready for another look.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍🏽

You then asked, and you 1/2 count (I assume you don't actually need this but are anticipating an actual user need)

I don't "need" it per se, but I ran into it by accident that day, while doing an unrelated test of uv as a python provider pants plugin. That's what ended up triggering my question, actually.

Just ran it now on that machine, and using any permutation of the gil-less, gil-full, and gil-ambiguous constraints work as I would expect now.

@jsirois jsirois changed the title Support CPython_t in ICs to select free-threaded CPython. Support CPython+t in ICs to select free-threaded CPython. Jan 11, 2026
@jsirois jsirois requested a review from sureshjoshi January 12, 2026 00:24
@jsirois jsirois merged commit 6070b4c into pex-tool:main Jan 12, 2026
52 of 54 checks passed
@jsirois jsirois deleted the IC/add-marker-form branch January 12, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants