-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python .zip in OutputGroupInfo is missing shebang line #17629
Comments
Seeing the same issue. Would really if there was a way around this issue. More importantly, is it possible for a downstream target to depend on the zip output of The way we are tackling this right now is to use a filegroup that generates this zip, and the downstream target(container rule) uses that filegroup output. Because the zip lacks the shebang, it needs to be invoked using a python interpreter inside the container. |
One workaround is to add the shebang manually in a genrule:
This will probably beak things on Windows though, since on windows an |
If an Also, if this is the case, that sounds like an inconsistency if the |
@aignas should this issue be transferred to rules_python perhaps? |
This issue is about the native implementation, so it should be probably closed as won't do. Users should migrate to rules_python instead of using the native rules. Feel free to create issues if they do not work in your context. |
I believe that this is a problem in rules_python as well:
|
Description of the bug:
The native
py_binary
implementation was amended in #9453 to export the zipped python executable in anOutputGroupInfo
namedpython_zip_file
. However, this archive is different than the one produced when building thepy_binary
with--build_python_zip
, since it does not include the shebang line needed to make the stub execute when invoked on the command line. This is because the action that prepends the shebang is gated on the command line flag:https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java#L252
This code path should be amended such that the artifact in the output group is the same as the one produced when building with the flag (i.e., remove the gating on the flag and have the resulting artifact populate the
OutputGroupInfo
and optionally be output directly when the flag is provided).What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
main.py
BUILD
Invoke:
bazel build :main_zip
Inspect:
hexdump -Cv bazel-bin/main.zip | head -n 10
Observe no shebang line.
Invoke:
bazel build :main --build_python_zip
Inspect:
hexdump -Cv bazel-bin/main | head -n 10
Observe a shebang line.
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 5.2.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: