Skip to content

fix(py_image_layer): Fix interpreter regex matching pip packages#822

Merged
arrdem merged 2 commits intomainfrom
arrdem/fix-787-image-layer-regex
Mar 19, 2026
Merged

fix(py_image_layer): Fix interpreter regex matching pip packages#822
arrdem merged 2 commits intomainfrom
arrdem/fix-787-image-layer-regex

Conversation

@arrdem
Copy link
Copy Markdown
Contributor

@arrdem arrdem commented Mar 6, 2026

The interpreter layer regex in py_image_layer was too broad — it matched any runfiles path segment containing both "python" and an architecture string. Pip packages with arch tags in their canonical repo name (e.g. rules_python++pip+pypi_313_argon2_cffi_bindings_cp36_abi3_manylinux_2_17_x86_64_...) were incorrectly placed in the interpreter layer.

New regex matches the interpreter repo naming convention: python[_]<major>_<minor>[_<patch>]_<arch>[-_]<vendor>[-_]<os>, keying on the platform triplet vendor field (unknown/apple/pc). Handles:

  • rules_python style with hyphens (python_3_9_x86_64-unknown-linux-gnu)
  • aspect_rules_py provisioned style with underscores (python_3_11_x86_64_unknown_linux_gnu)
  • Both bzlmod (+) and WORKSPACE (~) module separators

Fixes #787

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

Release note: Fix py_image_layer incorrectly placing pip packages with architecture strings in their name into the interpreter layer instead of the packages layer.

Test plan

  • New test: //py/tests/py_image_layer_regex:test_interpreter_regex — 19 assertions covering interpreter repos (both naming conventions), pip packages, and main repo paths
  • Covered by existing e2e OCI image layer tests

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 6, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ arrdem
❌ aspect-marvin
You have signed the CLA already but the status is still pending? Let us recheck it.

@arrdem arrdem force-pushed the arrdem/fix-787-image-layer-regex branch from 0ed1a3d to cde2a75 Compare March 19, 2026 19:20
@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Mar 19, 2026

Bazel 8 (Test)

All tests were cache hits

104 tests (100.0%) were fully cached saving 46s.


Bazel 9 (Test)

All tests were cache hits

104 tests (100.0%) were fully cached saving 1m 14s.


Bazel 8 (Test)

e2e

All tests were cache hits

34 tests (100.0%) were fully cached saving 20s.


Bazel 9 (Test)

e2e

All tests were cache hits

34 tests (100.0%) were fully cached saving 21s.


Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 444ms.

The interpreter layer regex was too broad — it matched any runfiles path
segment containing both "python" and an architecture string. This caused
pip packages with arch tags in their canonical repo name (e.g.
`rules_python++pip+pypi_313_argon2_cffi_bindings_cp36_abi3_manylinux_2_17_x86_64_...`)
to be incorrectly placed in the interpreter layer instead of packages.

Replace with a regex that matches the Python interpreter repo naming
convention: `python[_]<major>_<minor>[_<patch>]_<arch>[-_]<vendor>[-_]<os>`,
keying on the platform triplet vendor field (unknown/apple/pc). Handles
both rules_python style (hyphens) and aspect_rules_py provisioned style
(underscores), as well as both bzlmod (+) and WORKSPACE (~) separators.

Fixes #787
@arrdem arrdem force-pushed the arrdem/fix-787-image-layer-regex branch from 6bfe534 to 4fef9ef Compare March 19, 2026 19:22
@arrdem arrdem merged commit 0634d8d into main Mar 19, 2026
1 of 2 checks passed
@arrdem arrdem deleted the arrdem/fix-787-image-layer-regex branch March 19, 2026 19:36
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.

[Bug]: py_image_layer is adding some pypi deps to the "interpreter" layer?

3 participants