You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A py_pex_binary will fail to build if the binary it's given includes a file called main.py. Unfortunately, this is a common pattern because Gazelle uses it as a signal to create a binary target from the file.
Version
Development (host) and target OS/architectures:
Output of bazel --version: bazel 7.1.1
Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file: v1.0.0
This is an example of the kind of binary target generated by Gazelle and the pex target using it:
py_binary(
name = "gazelle_generated_main",
srcs = ["__main__.py"],
imports = [".."],
main = "__main__.py",
)
py_pex_binary(
name = "my_pex",
binary = ":gazelle_generated_main",
)
This generates an error like:
Traceback (most recent call last):
File "/home/alex/.cache/bazel/_bazel_alex/5413ef0fb20af199ccb77fe9356d6bd5/sandbox/processwrapper-sandbox/1552/execroot/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/aspect_rules_py/py/tools/pex/main.py", line 190, in <module>
pex_builder.freeze(bytecode_compile=False)
File "/home/alex/.cache/bazel/_bazel_alex/5413ef0fb20af199ccb77fe9356d6bd5/sandbox/processwrapper-sandbox/1552/execroot/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/pex_builder.py", line 692, in freeze
self._prepare_code()
File "/home/alex/.cache/bazel/_bazel_alex/5413ef0fb20af199ccb77fe9356d6bd5/sandbox/processwrapper-sandbox/1552/execroot/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/pex_builder.py", line 607, in _prepare_code
self._chroot.write(
File "/home/alex/.cache/bazel/_bazel_alex/5413ef0fb20af199ccb77fe9356d6bd5/sandbox/processwrapper-sandbox/1552/execroot/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/common.py", line 623, in write
self._tag(dst, label, compress)
File "/home/alex/.cache/bazel/_bazel_alex/5413ef0fb20af199ccb77fe9356d6bd5/sandbox/processwrapper-sandbox/1552/execroot/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/common.py", line 541, in _tag
self._check_tag(fn, label, compress)
File "/home/alex/.cache/bazel/_bazel_alex/5413ef0fb20af199ccb77fe9356d6bd5/sandbox/processwrapper-sandbox/1552/execroot/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/common.py", line 521, in _check_tag
raise self.ChrootTaggingException(
pex.common.Chroot.ChrootTaggingException: Trying to add __main__.py to fileset(main) but already in fileset(executable)!
The text was updated successfully, but these errors were encountered:
What happened?
A py_pex_binary will fail to build if the binary it's given includes a file called main.py. Unfortunately, this is a common pattern because Gazelle uses it as a signal to create a binary target from the file.
Version
Development (host) and target OS/architectures:
Output of
bazel --version
:bazel 7.1.1
Version of the Aspect rules, or other relevant rules from your
WORKSPACE
orMODULE.bazel
file: v1.0.0Language(s) and/or frameworks involved: Python 3.9, Bazel, Gazelle
How to reproduce
This generates an error like:
The text was updated successfully, but these errors were encountered: