zipapp exploded the python interpreter

Open
#4,163 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
build-system

Research direction

Start by reproducing the zipapp contents shown in the issue and tracing how the Python 3.10 interpreter and libraries are gathered into the archive. Done means the static interpreter is not duplicated under multiple names and unnecessary shared libraries are no longer packed, while the resulting zipapp still runs correctly.

Written by the indexing model from the issue text.

Description

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
...
Dominant language
Starlark
Stars
690
Forks
722
Avg merge
18h 7m
Merged PRs (30d)
56

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazel-contrib/rules_python

All issues in bazel-contrib/rules_python

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.