Skip to content

components: add pip repo for Python distributions - #167

Open
yeetypete wants to merge 4 commits into
coreos:mainfrom
yeetypete:feat/pip-backend
Open

yeetypete wants to merge 4 commits into
coreos:mainfrom
yeetypete:feat/pip-backend

Conversation

@yeetypete

@yeetypete yeetypete commented Aug 27, 2026 •

Copy link
Copy Markdown

Add a component repo for Python distributions installed by pip, uv, or any other installer following the "Recording installed projects" specification (PEP 376).

chunkah is pretty nice for Python-heavy images. Any ML/CUDA venvs can get to be 10s of gigs in size 😅. The classic workaround is to manually split the installation into separate RUN commands so large dependencies land in their own layers (see astral-sh/uv#16113 and astral-sh/uv#7712). With this, each distribution becomes its own component and layers can be reused across updates regardless of how the image was built.

How it works:

  • Files listed in RECORD are strongly claimed, along with their parent directories up to site-packages. Directories shared between distributions end up in each component's layer, as with the other repos.
  • Names are normalized per PEP 503, so Foo_Pkg-1.2.3.dist-info becomes pip/foo-pkg.
  • Bytecode compiled after installation (not in RECORD, e.g. by uv's --compile-bytecode) is claimed for the component owning the corresponding .py.
  • Distributions vendored inside another one (e.g. setuptools/_vendor, see Stop vendoring packages pypa/setuptools#2825) belong to the outer distribution.
  • We set the PipRepo priority below distro package managers so Python packages installed by the distro package manager stay with the distro package.
  • PyPI packages don't have any changelog data. We assume a fixed 30-day update interval for stability.

Assisted-by: AI
Assistance-level: 4

@yeetypete

Copy link
Copy Markdown
Author

@jlebon if you have a chance to take a look that would be great! I think this could be a big win for people doing ML stuff with lage Python wheels + using containerization :)

@jlebon jlebon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this! I'm mostly AFK these days which is why turnaround is slow. Please bear with me until I'm fully back online. :)

Alongside the AI disclosure, one thing that would be helpful (which I'd like to eventually reflect in the guidelines) is basically alongside Assisted-by: AI, to have something like Assistance-level: which would specify e.g. some level on a spectrum (a recent proposed strawman I saw go by was https://sph.sh/en/posts/ai-assistance-spectrum-professional-software-engineering/ but I'm sure there are others). All this to ask: how much time/effort was spent on reviewing the AI output?

Commit bac2943 should be folded into commit 067d612. Commit 89824ea should be split per-file and folded into the respective earlier commits which add those files. (Also fine if you just fold the e2e test into 067d612.)

Comment thread src/components/pip.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question before reviewing this more deeply: did you check if there were any pure Rust libraries (with minimal deps) which can parse the dist-info format into nice data structures already? For ALPM the answer was no (at least at the time), which is why we went ahead and implemented a basic parser.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I took a look at a collection of uv crates including uv-install-wheel that could be useful. They provide RECORD parsing, wheel / sdist file name parsing, and METADATA structs. The implementation here closely follows the uv one.

Unfortunately uv advertises all published internal crates as unstable so I'm not sure it would be a great idea to use them here: https://github.com/astral-sh/uv/blob/main/docs/reference/policies/versioning.md#crate-versioning. These crates also pull in a lot of other unrelated uv and third party crates that we don't really need.

@yeetypete

yeetypete commented Sep 18, 2026 •

Copy link
Copy Markdown
Author

Alongside the AI disclosure, one thing that would be helpful (which I'd like to eventually reflect in the guidelines) is basically alongside Assisted-by: AI, to have something like Assistance-level

Thats a neat post, I updated the PR description to include this. As is expected I fully self-reviewed the code before submitting the PR :)

@yeetypete
yeetypete force-pushed the feat/pip-backend branch 2 times, most recently from 3454668 to b489dea Compare September 18, 2026 22:48
@yeetypete
yeetypete requested a review from jlebon October 17, 2026 17:11
Signed-off-by: Peter Siegel <psiegel2000@icloud.com>
Add a component repo for Python distributions installed by pip, uv, or
any other installer following the "Recording installed projects" spec.
Distributions are discovered via their `*.dist-info/RECORD` files
anywhere in the rootfs, so this covers system site-packages as well as
virtualenvs. Files listed in RECORD are strongly claimed, along with
their parent directories up to site-packages. Bytecode compiled after
installation (not in RECORD) is claimed for the component owning the
corresponding source file.

Distributions vendored inside another distribution (e.g.
setuptools/_vendor, see pypa/setuptools#2825)
belong to the outer distribution.

The repo is below distro package managers in priority so that Python
packages installed by the distro package manager stay with their distro
package.

Assisted-by: AI
Signed-off-by: Peter Siegel <psiegel2000@icloud.com>
Install packages with pip into system site-packages and with uv into a
venv, and check that they become pip components while rpm-installed
Python packages stay with rpm. Covers bytecode recorded in RECORD (pip),
bytecode compiled at install time (uv --compile-bytecode), and
distributions vendored inside setuptools.

Assisted-by: AI
Signed-off-by: Peter Siegel <psiegel2000@icloud.com>
Signed-off-by: Peter Siegel <psiegel2000@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants