-
-
Notifications
You must be signed in to change notification settings - Fork 722
fix(zipapp): reduce bundled interpreter size #4165
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
68cb8f8
08e599c
d586969
1e66012
63244d9
2ab0e89
8303a1f
c77035b
f575790
c6d3fe3
2aa11ee
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,4 @@ | ||
| (zipapp) Reduced self-contained archive sizes by preserving Python executable | ||
| symlinks instead of storing each alias as another copy of the interpreter, and | ||
| by omitting shared `libpython` files from recognized statically linked Astral | ||
| runtime builds. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| """Helper functions to parse python-build-standalone manifests.""" | ||
|
|
||
| _ASTRAL_STATIC_LIBPYTHON_RELEASE = 20250517 | ||
| _ASTRAL_RELEASE_URL_PREFIXES = [ | ||
| "https://github.com/astral-sh/python-build-standalone/releases/download/", | ||
| "https://releases.astral.sh/github/python-build-standalone/releases/download/", | ||
| ] | ||
|
|
||
| def parse_filename(filename): | ||
| """Parses a python-build-standalone filename (or URL) into its components. | ||
|
|
||
|
|
@@ -112,6 +118,28 @@ def parse_filename(filename): | |
| "vendor": vendor, | ||
| } | ||
|
|
||
| # buildifier: disable=function-docstring-args | ||
| # buildifier: disable=function-docstring-return | ||
| # urls: list[str], release_filename: str -> bool | ||
| def is_astral_static_libpython_build(urls, release_filename): | ||
| """Whether an Astral build includes libpython statically in its interpreter.""" | ||
| parsed = parse_filename(release_filename) | ||
| if not parsed: | ||
| return False | ||
|
|
||
| build_version = parsed["build_version"] | ||
| if ( | ||
| not build_version.isdigit() or | ||
| int(build_version) < _ASTRAL_STATIC_LIBPYTHON_RELEASE | ||
| ): | ||
| return False | ||
|
|
||
| return any([ | ||
| url.startswith(prefix) | ||
| for url in urls | ||
| for prefix in _ASTRAL_RELEASE_URL_PREFIXES | ||
|
Collaborator
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. Is the thinking here that only astral releases are supported and if someone is re-hosting this from their local, they will not be able to benefit from this? I am thinking that it probably makes sense to expose a flag in the
Contributor
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. Resolved in 2ab0e89 |
||
| ]) | ||
|
|
||
| def parse_runtime_manifest(content): | ||
| """Parses the SHA256SUMS file content into a list of structs. | ||
|
|
||
|
|
||
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.
This is saving a little bit of time instead of readability for later. Consider adding a comment that includes type-hints for the args, since this would be a trivial addition.
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.
Resolved in 2ab0e89