Add :python option to uv_init/2 for free-threaded Python support#45
Merged
jonatanklosko merged 2 commits intolivebook-dev:mainfrom Feb 16, 2026
Merged
Add :python option to uv_init/2 for free-threaded Python support#45jonatanklosko merged 2 commits intolivebook-dev:mainfrom
jonatanklosko merged 2 commits intolivebook-dev:mainfrom
Conversation
Allow specifying the Python version passed to uv via --python, enabling users to request free-threaded Python builds (e.g., "3.14t"). The python option is included in the project cache key so different variants get separate cache directories.
josevalim
approved these changes
Feb 15, 2026
Contributor
josevalim
left a comment
There was a problem hiding this comment.
This looks simple and lightweight enough to me!
jonatanklosko
approved these changes
Feb 16, 2026
Member
jonatanklosko
left a comment
There was a problem hiding this comment.
Ideally we would be able to specify it via pyproject.toml, but from what I checked that's not possible. That said, I think the option doesn't hurt and we can revisit as things change.
Contributor
Author
|
@jonatanklosko yes I agree. I was trying to find the least resistance path while python ecosystem resolving it :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
:pythonoption toPythonx.uv_init/2that gets passed as--pythontouv sync, allowing users to request a specific Python variant — most notably free-threaded builds like"3.14t".Motivation
Free-threaded Python (experimental in 3.13t, officially supported in 3.14t) removes the GIL, enabling true parallelism when calling
Pythonx.eval/2from multiple Elixir processes concurrently. As noted in#23 and #39, this has been a requested feature. Now that Python 3.14t is officially supported and uv can install free-threaded builds via
--python, this can be offered as an opt-in option without anybreaking changes.
No C++ NIF changes are needed —
PyEval_RestoreThread/PyEval_SaveThreadstill exist in free-threaded Python as lightweight no-ops, and the wildcardlib/libpython3.*{.dylib,.so}already matcheslibpython3.14t.{dylib,so}.Changes
Follows the same pattern as
:native_tls(#41):lib/pythonx.ex— Adds:pythonto opts validation and documentation, threads it through toUv.fetch/3andUv.init/3lib/pythonx/uv.ex— Accepts:pythoninfetch/3andinit/3, passes--python <version>touv syncwhen set, and includes the python value in theproject_dircache key MD5 so that differentvariants (e.g.,
3.14vs3.14t) get separate cache directoriesUsage