Skip to content

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

@dougthor42

Description

@dougthor42

What happened?

I was poking around with https://github.com/wagoodman/dive on an image created with py_image_layers and rules_oci, trying to debug something (most likely) unrelated to py_image_layers, and noticed that the interpreter layer seems to include some pypi-sourced dependencies.

It was my understanding that the interpreter layer should only include the rules_python++python+python_3_13_6_x86_64-unknown-linux-gnu stuff. However, I'm seeing things like rules_python++pip+pypi_313_argon2_cffi_bindings_cp36_abi3_manylinux_2_17_x86_64_b746dba8 and rules_python++pip+pypi_313_cryptography_cp39_abi3_manylinux_2_17_x86_64_58d4e912 in the layer, which include all of the python code for that dependency:

Image

If I pop down to the packages layer, the rest of the dependencies show up:

Image

Am I misunderstanding what the interpreter layer is supposed to be? Or is this an actual bug?

Version

Development (host) and target OS/architectures:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux rodete
Release:        n/a
Codename:       rodete
$ uname -m
x86_64

Output of bazel --version:

$ bazel version
Bazelisk version: v1.26.0
Build label: 8.3.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Jun 30 16:23:40 2025 (1751300620)
Build timestamp: 1751300620
Build timestamp as int: 1751300620

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_rules_py", version = "1.6.3")

Language(s) and/or frameworks involved:

Python, rules_python 1.7.0-rc4, rules_oci 2.2.6

How to reproduce

Build a basic `oci_image` that uses `py_image_layer`, then use a tool like https://github.com/wagoodman/dive to inspect the image layers.

Roughly:


py_binary(
    name = "my_py_bin":
    srcs = ["my_py_bin.py"],
    deps = [
        # some pip deps
    ],
)

py_image_layer(
    name = "foo",
    binary = ":my_py_bin",
)

oci_image(
    name = "foo_image",
    base = "@distroless_python3",
    tars = [":foo"],
)

oci_load(
    name = "foo_image.load",
    image = ":foo_image",
    repo_tags = "foo:latest",
)

Any other information?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions