Repository navigation
docs(proposals): add proposal for multiple target Python interpreters #1482
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Build wheels for multiple target Python interpreters | ||
|
|
||
| - Author: Christian Heimes | ||
| - Created: 2026-11-20 | ||
| - Status: Open | ||
| - Epic: [#1480](https://github.com/python-wheel-build/fromager/issues/1480) | ||
|
|
||
| ## Problem | ||
|
|
||
| Fromager builds wheels for the interpreter that runs it. If you need wheels | ||
| for a second Python version, you run Fromager again in a second environment. | ||
| You then keep the two outputs apart and combine them yourself. This costs time | ||
| and is easy to get wrong. Fromager can pick the wrong wheel. It can check | ||
| Python version requirements against the wrong interpreter, or overwrite one | ||
| variant with another. | ||
|
|
||
| Python 3.14 makes this worse. `cp314` is the normal build, and `cp314t` is the | ||
| free-threaded build. A wheel for one does not work on the other, so a single | ||
| bootstrap run should produce both. Dependencies can depend on the target too. | ||
| Bootstrap checks a marker such as `foo; python_version < "3.14"` once, with the | ||
| interpreter that runs Fromager. With several targets, one answer is wrong for | ||
| at least one target. | ||
|
|
||
| Older Python versions are a second case. Fromager requires Python 3.12 or | ||
| newer, but some downstreams still need wheels for 3.10 and 3.11. Today the | ||
| only path is an old Fromager release in an old environment. A target is a | ||
| build environment, so the Fromager runtime version does not have to match it. | ||
| This case depends on the Python stack. uv, build, packaging, and the build | ||
| backends must still support the target version. When they drop a version, it | ||
| stops being a usable target. | ||
|
|
||
| ## Intended outcome | ||
|
|
||
| Fromager accepts one primary target and zero or more additional targets. If | ||
| you set no target, behavior stays the same, and Fromager builds for its | ||
| runtime Python interpreter. A target can be older than the Fromager runtime. | ||
| You can build 3.10 or 3.11 wheels with Fromager on 3.12 or newer. | ||
|
|
||
| Fromager builds the primary target first. It builds an additional target only | ||
| if the primary wheel cannot serve it. It builds a pure Python wheel once, and | ||
| a GIL stable-ABI wheel such as `cp312-abi3` covers Python 3.12 and newer but | ||
| not free-threaded builds. Fromager judges compatibility from wheel tags. | ||
| Python 3.15 ships multi-ABI wheels such as `cp315-abi3.abi3t`. One such wheel | ||
| serves both the GIL target and the free-threaded target, so neither needs a | ||
| second build. | ||
|
|
||
| One run produces all requested wheels, and they are distinguishable. One | ||
| variant does not overwrite another, and you do not move files between | ||
| directories by hand. | ||
|
|
||
| Resolution runs once per target. Environment markers, prebuilt wheel reuse, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am assuming we will need graph and constraints one for each target, am I right?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also don't know. We may be able to extend the graph with dependency markers or create separate graphs for each Python version.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good |
||
| and `Requires-Python` checks all use that target, not the interpreter that runs | ||
| Fromager. A requirement such as `foo; python_version < "3.14"` applies to the | ||
| targets it matches. Requirements can also demand different versions for | ||
| different targets, for example `foo<2; python_version < "3.14"` and | ||
| `foo>=2; python_version >= "3.14"`. When they do, each target builds the | ||
| version its marker selects. The extra resolution passes reuse cached index | ||
| data, so they stay cheap. | ||
|
|
||
| Reports, the SBOM, and logs record the target for each wheel. If Fromager | ||
| cannot produce a requested variant, it reports that and names the target and | ||
| the distribution. | ||
|
|
||
| Each target is either required or optional. Fromager fails the run when a | ||
| required target cannot build a distribution. A `Requires-Python` exclusion is | ||
| not a failure, so Fromager skips that distribution for the target. An optional | ||
| target skips a distribution that fails to build, and it reports each skip. A | ||
| skip also applies to packages that need the skipped distribution for that | ||
| target, and the report lists them. Optional targets let a downstream adopt a | ||
| newer Python in steps: mark the new target optional while packages catch up, | ||
| then make it required. | ||
|
|
||
| ## Scope | ||
|
|
||
| - Target interpreters that the user supplies or that are already installed. | ||
| - Targets older than the Fromager runtime, such as 3.10 and 3.11. | ||
| - One Fromager run for a primary target and any number of additional targets. | ||
| - Required and optional targets, so a downstream can adopt a newer Python | ||
| version gradually. | ||
| - Resolution, dependency markers, build environments, wheel output, reports, | ||
| the SBOM, and logs. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Cross-compile for another OS, architecture, or libc. | ||
| - Download or manage Python interpreters. The user provides the targets or | ||
| already has them installed. uv-managed Python may be an option, but the | ||
| details are out of scope. | ||
| - Run builds in parallel as an end in itself. | ||
|
|
||
| ## Open questions | ||
|
|
||
| - How to declare targets, and what to call them. A CPython wheel ABI tag such | ||
| as `cp312` or `cp314t` is a possible option, because it names the version | ||
| and threading mode. | ||
| - Which target becomes the primary one: the first declared entry or the oldest | ||
| Python version. | ||
| - Which naming and build tag scheme keeps variants unambiguous downstream. | ||
| - What happens when the primary variant of a distribution fails but an | ||
| additional target could still build. | ||
| - Whether the primary target can be optional. | ||
| - How the primary-first rule applies. One option builds both variants of a | ||
| distribution before the next one. Another finishes the primary bootstrap | ||
| first. | ||
| - What exit code Fromager uses when optional targets skip distributions: | ||
| success, or a distinct soft-failure code. | ||
| - How old a target can be, given the Python versions that uv, build, | ||
| packaging, and the build backends still support. | ||
| - How Fromager recognizes that one multi-ABI wheel serves both the GIL and | ||
| free-threaded targets, and how that changes the skip decision. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open Question: does each target get its own
WorkContext, or does one context carry a list of targets? This affects every plugin hook that takes ctx.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, yet.