You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using python 3.10 and the static python3 interpreter binary is about 45MB, but zipapp packs it three times so we end up with 150MB just for the interpreter alone, making the zipapp binary bloated.
$ ls -l runfiles/rules_python++python+python_3_10_x86_64-unknown-linux-gnu/bin/python*
-rwxrwxr-x 1 koi koi 44667000 Jan 1 1980 python
-rwxrwxr-x 1 koi koi 44667000 Jan 1 1980 python3
-rwxrwxr-x 1 koi koi 3149 Jan 1 1980 python3-config
-rwxrwxr-x 1 koi koi 44667000 Jan 1 1980 python3.10
-rwxrwxr-x 1 koi koi 3149 Jan 1 1980 python3.10-config
Also the static interpreter wouldn't need the shared libraries, but that is also being packed into zipapp, increase the size by another 45MB:
$ ls -l runfiles/rules_python++python+python_3_10_x86_64-unknown-linux-gnu/lib/
-rwxrwxr-x 1 koi koi 45131088 Jan 1 1980 libpython3.10.so.1.0
-rwxrwxr-x 1 koi koi 16800 Jan 1 1980 libpython3.so
-rwxrwxr-x 1 koi koi 2340016 Jan 1 1980 libtcl9.0.so
-rwxrwxr-x 1 koi koi 3082472 Jan 1 1980 libtcl9tk9.0.so
...
@aignas https://github.com/bazel-contrib/rules_python/blob/main/python/versions.bzl#L339
Is there a reason why we didn't prefer the stripped python interpreter by default so we can have smaller size?
It seems "install_only" Astral python-build-standalone package is being used by default, at least on linux x86_64, can we change to install_only_stripped ?
Is there a reason why we didn't prefer the stripped python interpreter by default so we can have smaller size?
I don't recall a particular reason. It's handy to have debugging symbols available by default when C code crashes. Do you want a build flag to pick the install flavor? I have a WIP change for that, but I put it on the backburner because I didn't see user requests for something like that and the size different didn't seem that big (relative to all the other stuff that gets downloaded when building a non-trivial python app).
@aignashttps://github.com/bazel-contrib/rules_python/blob/main/python/versions.bzl#L339 Is there a reason why we didn't prefer the stripped python interpreter by default so we can have smaller size? It seems "install_only" Astral python-build-standalone package is being used by default, at least on linux x86_64, can we change to install_only_stripped ?
Reason is probably history - when the toolchains were added the binaries provided by the standalone python project were definitely different, but I can't remember if there were stripped symbols at the time.
TBH, selecting strict vs non strict based on some debug flag would be nice.
Activity
aignas commentedon Sep 17, 2026
So there are 2 root causes:
Anything else to note here? I think the second bullet point is a new thing which should be scope of this ticket.
gfrankliu commentedon Sep 22, 2026
@aignas
https://github.com/bazel-contrib/rules_python/blob/main/python/versions.bzl#L339
Is there a reason why we didn't prefer the stripped python interpreter by default so we can have smaller size?
It seems "install_only" Astral python-build-standalone package is being used by default, at least on linux x86_64, can we change to
install_only_stripped?fix(zipapp): reduce bundled interpreter size (bazel-contrib#4165)
fix(zipapp): reduce bundled interpreter size (#4165)
rickeylev commentedon Sep 28, 2026
I don't recall a particular reason. It's handy to have debugging symbols available by default when C code crashes. Do you want a build flag to pick the install flavor? I have a WIP change for that, but I put it on the backburner because I didn't see user requests for something like that and the size different didn't seem that big (relative to all the other stuff that gets downloaded when building a non-trivial python app).
aignas commentedon Sep 28, 2026
Reason is probably history - when the toolchains were added the binaries provided by the standalone python project were definitely different, but I can't remember if there were stripped symbols at the time.
TBH, selecting strict vs non strict based on some debug flag would be nice.
feat(toolchains): allow selecting stripped python-build-standalone ar…