Conversation
…chives Runtimes always used install_only archives, which include debug symbols. The install_only_stripped variants are much smaller; for example, a Python 3.14 zipapp shrinks from 147 MB to 65 MB. Add python.override(archive_flavor) with install_only (default), install_only_stripped, and full. The manifest sort key is shared and prefers the selected flavor, falling back when unavailable. Built-in manifest entries now include stripped archive hashes for releases from 20240726 onward, sourced from the official SHA256SUMS files. Fixes bazel-contrib#4163
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add coverage for the full flavor and address the noted release-note and formatting issues.
Review effort: Lite
Findings: 1
Open (4)
What changed in this PR
Adds configurable Python standalone archive flavors, including stripped archives and fallback selection.
Changes:
- Adds
archive_flavoroverride support. - Updates manifest ranking and stripped archive hashes.
- Adds tests, documentation, mocks, and release notes.
| File | Summary |
|---|---|
tests/support/mocks/python_ext.bzl |
Updates mock override attributes. |
tests/python/python_tests.bzl |
Tests archive selection and fallback behavior. |
python/versions.bzl |
Reuses shared manifest sorting. |
python/private/runtimes_manifest.txt |
Adds stripped archive checksums. |
python/private/python.bzl |
Implements archive flavor configuration. |
python/private/pbs_manifest.bzl |
Defines flavor-aware manifest ranking. |
news/stripped-python-archives.added.md |
Adds the release note. |
docs/toolchains.md |
Documents archive flavor selection. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Add a test that selects the full flavor and checks its URL, sha256, and
python/install strip prefix, including fallback to install_only.
- Reuse ARCHIVE_FLAVORS for the attr values and in versions.bzl.
- Wrap test lines exceeding 100 columns.
- Rename news entry to 4163.added.md, use {obj}, and add the issue link.
|
There are two ways about this - have the config at the extension level or via config flags. I think I would prefer the later. Usecase - if I need to optimize the space, I use the stripped version, if not, non-stripped, that may provided extra diagnostic output if the system crashes. I may want to push both variants from the CICD so that dev-like envs can have the larger binaries and prod-like have stripped versions. Let me know what you think. |
Agreed, a flag fits the dev/prod use case much better, since the extension setting locks a workspace to one flavor. My plan: add a //python/config_settings:py_stripped flag (yes/no, default no). Register stripped toolchain variants alongside the regular ones, the same way freethreaded variants work, falling back to install_only for older releases that have no stripped archive. Drop the python.override(archive_flavor) attribute and leave full out of scope. Does that naming and scope sound right? |
Oh, good point. Yeah, i'd prefer a build-time flag, too.
Name, values and default: SGTM. Is there a well known term for what the "full" vs "install_only" vs "install_only_stripped" types of archives are? In the code, i called it "archive flavor" for lack of a better term. I'm somewhat torn as to whether the name should be expressing intent ("--py_stripped=yes" means "i want stripping") or expressing the desired archive type ("--archive_type=install_only_stripped", which means you know you're getting more than just stripping). |
|
Overall plan sounds good. Regarding naming, a few more ideas:
I am of opinion that just using fragments from the archive name to disambiguate may be nice. If they start shipping binaries with different optimizations, that could fit the bill. |
|
Thanks both. I don't know of an established term: PBS's docs call the builds "distributions", but nothing names the full/install_only/stripped distinction specifically. I like aignas's direction of archive-type values with
One open question: when the selected archive doesn't exist for a version/platform (e.g. stripped archives before 20240726), should we fall back to install_only, or fail toolchain resolution? I'd lean toward falling back and documenting it, since a "no matching toolchain" error is hard to diagnose, but it makes the flag a preference rather than a guarantee. |
+1 for falling back. The user can do the fail if they override the toolchains and remove the URLs/sources that they do not wish to use (I think that may be possible, if it is not I think that could be a good direction to investigate if anyone needs it). |
|
Yeah, +1 to falling back |
Per review, select the python-build-standalone archive with a build flag instead of a module extension setting, so one workspace can build both stripped and unstripped runtimes (e.g. dev vs prod). - Add //python/config_settings:py_pbs_distribution with values auto (default, same as install_only), install_only, install_only_stripped, and full. It is transition-enabled. - Register -install_only_stripped and -full platform variants next to the existing platforms, like -freethreaded. Only the selected runtime is downloaded. - When a version or platform has no archive of the selected kind, fall back to the install_only archive. Per-platform libpython, coverage_tool, and patches settings carry over to the variants. - Keep the host interpreter on the plain runtime. - Remove python.override(archive_flavor).
|
Thanks both, implemented in b16dc46 as discussed:
Two things worth flagging:
|
|
FYI, if the build is with @rickeylev, WDYT? |
I think that is fine.
I think that is also fine. I think users that are overriding the individual archives know what they are doing and will probably do the overrides for the other platforms as well or for a particular archive type. |


Hermetic runtimes always used install_only archives, which include debug symbols. The install_only_stripped variants are much smaller; for example, a Python 3.14 zipapp shrinks from 147 MB to 65 MB.
Add the
--@rules_python//python/config_settings:py_pbs_distributionflag to select the archive:auto(default, currentlyinstall_only),install_only,install_only_stripped, orfull. Because it is a build flag, one workspace can build stripped and unstripped runtimes, e.g. for prod and dev.Toolchains are registered for each archive kind as
-install_only_strippedand-fullplatform variants, like-freethreaded; only the selected runtime is downloaded. If a version or platform has no archive of the selected kind, the install_only archive is used. Built-in manifest entries now include stripped archive hashes for releases from 20240726 onward, sourced from the official SHA256SUMS files.Fixes #4163