aspect-build / aspect-build/rules_py

[Bug]: `py_pex_binary` fails with `AmbiguousDistributionError`

Open
#408 2 comments 4 reactions 1 assignee Claimed by @arrdem View on GitHub
bug feature: pex prioritized
Dominant language
Starlark
Stars
145
Forks
97
Avg merge
1d 1h
Merged PRs (30d)
71

Description

### What happened?

Building `py_pex_binary` fails with:

```
Traceback (most recent call last):
File "/home/playground/.cache/bazel/_bazel_playground/33746cb7bfc65ca42552dbe5cbc93007/execroot/ntropy/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/aspect_rules_py/py/tools/pex/main.py", line 162, in
dist = Distribution.load(dep + "/../")
File "/home/playground/.cache/bazel/_bazel_playground/33746cb7bfc65ca42552dbe5cbc93007/execroot/ntropy/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/dist_metadata.py", line 885, in load
return cls(location=location, metadata=DistMetadata.load(location))
File "/home/playground/.cache/bazel/_bazel_playground/33746cb7bfc65ca42552dbe5cbc93007/execroot/ntropy/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/dist_metadata.py", line 805, in load
metadata_files = load_metadata(location, restrict_types_to=restrict_types_to)
File "/home/playground/.cache/bazel/_bazel_playground/33746cb7bfc65ca42552dbe5cbc93007/execroot/ntropy/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_py/py/tools/pex/pex.runfiles/.pex.venv/lib/python3.9/site-packages/pex/dist_metadata.py", line 363, in load_metadata
raise AmbiguousDistributionError(
pex.dist_metadata.AmbiguousDistributionError: Found more than one distribution inside external/python3_9_x86_64-unknown-linux-gnu/lib/python3.9/site-packages/_distutils_hack/../:
pip-23.2.1.dist-info/METADATA
setuptools-68.2.2.dist-info/METADATA
```

### Version

Development (host) and target OS/architectures:

Output of `bazel --version`:
bazel 6.5.0

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

Language(s) and/or frameworks involved:
python3.9

### How to reproduce

```shell
py_binary(
name = "binary",
srcs = [
"__init__.py",
],
main = "__init__.py",
visibility = ["//visibility:public"],
)

py_pex_binary(
name = "py_pex_binary",
binary = ":binary",
)
```
```

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.