Skip to content

[Bug]: py_binary expression expands to more than one file #455

Open
@keith

Description

@keith

What happened?

Using rules_python's py_binary like this:

py_binary(
    name = "upstream_py_binary",
    srcs = ["say.py"],
    main = "say.py",
)

py_binary(
    name = "upstream_py_binary2",
    srcs = ["say.py"],
    main = "say.py",
    data = [":upstream_py_binary"],
    env = {"FOO": "$(execpath :upstream_py_binary)"},
)

Works fine, but if you do the same with rules_py's py_binary, you get this error:

ERROR: /home/ubuntu/dev/bazelbuild/rules_py/examples/py_binary/BUILD.bazel:9:10: in py_binary rule //examples/py_binary:py_binary2: label '//examples/py_binary:py_binary' in $(location) expression expands to more than one file, please use $(locations //examples/py_binary:py_binary) instead.  Files (at most 5 shown) are: [bazel-out/aarch64-fastbuild/bin/examples/py_binary/py_binary, bazel-out/aarch64-fastbuild/bin/examples/py_binary/py_binary.venv.pth, examples/py_binary/say.py]

Version

Development (host) and target OS/architectures: ubuntu 22.04

Output of bazel --version: bazel 7.4.0

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

How to reproduce

On this branch: #456

bazel build :upstream_py_binary2 works fine
bazel build :py_binary2 fails with the above error

Any other information?

No response

Metadata

Metadata

Assignees

No one assigned

    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