Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PyExecutableInfo.runfiles_without_exe includes full interpreter exe with standard libraryΒ #3181

@malt3

Description

@malt3

🐞 bug report

Affected Rule

The issue is caused by the rule: py_binary

Is this a regression?

This has probably been broken since it was introduced.

Description

I'd like to build container images where the interpreter + standard library is part of a base image and the "app" layer contains just my python code (and explicit data dependencies).
I tried to write a small rule that extracts the necessary info from the provider to avoid pulling in the Python interpreter itself.
Looking at the output, the runfiles include the full interpreter, which is unexpected.

πŸ”¬ Minimal Reproduction

I have a working branch on tweag/rules_img: https://github.com/tweag/rules_img/tree/python_example/e2e/python

In the subdirectory e2e/python, I have a clean example of what I mean with a separate MODULE.bazel and a clean reproducer.
e2e/python/BUILD.bazel contains a py_binary and my custom rule for creating a "light" binary (using PyExecutableInfo).
e2e/python/extract_python_files/defs.bzl contains the rule I wrote to extract only the data I want.

Here are the repro steps:

  • bazel build :app
  • find bazel-bin/app.runfiles/

πŸ”₯ Exception or Error

You can see may files that shouldn't be there, including bazel-bin/app.runfiles/rules_python++python+python_3_13_x86_64-unknown-linux-gnu/bin/python3.13

🌍 Your Environment

Operating System:

  
NixOS 24.11 on amd64
  

Output of bazel version:

  
Bazelisk version: development
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
  

Rules_python version:

  
bazel_dep(name = "rules_python", version = "1.5.3")
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-rulesIssues concerning core bin/test/lib rules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions