-
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
ctx.expand_location() on py_binary expands to multiple files #20038
Labels
P3
We're not considering working on this, but happy to review a PR. (No assignee)
team-Rules-API
API for writing rules/aspects: providers, runfiles, actions, artifacts
type: bug
Comments
related: #16381 |
rakshitasingh05
added
the
team-Rules-API
API for writing rules/aspects: providers, runfiles, actions, artifacts
label
Nov 3, 2023
comius
added
P3
We're not considering working on this, but happy to review a PR. (No assignee)
and removed
untriaged
labels
Nov 3, 2023
Does this mean that https://github.com/bazelbuild/bazel/pull/16381/files/d8176177c95ff90c471db2c46085dfbc93fca4c1, the issue should be fixed? |
It looks like the fix was rolled back: ab71a10 Is there any resolution to this? Even if the the |
This was referenced Dec 10, 2024
fmeum
added a commit
to fmeum/bazel
that referenced
this issue
Jan 9, 2025
Work towards bazelbuild#11820 Fixes bazelbuild#20038 Fixes bazelbuild#23200 Fixes bazelbuild#24613 RELNOTES: Extra targets provided to `ctx.expand_location` now expand to their executable (if any) instead of resulting in an error if they provide a number of files different from one. RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag has been added and enabled, which makes it so that `ctx.expand_location` expands `$(locations :x)` to the executable of an extra target `:x` if it provides one and the number of files provided by it is not one. Closes bazelbuild#24690. PiperOrigin-RevId: 713453768 Change-Id: I0d6e052bc70deea029554ab722feb544f9597a23 (cherry picked from commit 457d248)
github-merge-queue bot
pushed a commit
that referenced
this issue
Jan 9, 2025
…24874) Work towards #11820 Fixes #20038 Fixes #23200 Fixes #24613 RELNOTES: Extra targets provided to `ctx.expand_location` now expand to their executable (if any) instead of resulting in an error if they provide a number of files different from one. RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag has been added and enabled, which makes it so that `ctx.expand_location` expands `$(locations :x)` to the executable of an extra target `:x` if it provides one and the number of files provided by it is not one. Closes #24690. PiperOrigin-RevId: 713453768 Change-Id: I0d6e052bc70deea029554ab722feb544f9597a23 (cherry picked from commit 457d248) Fixes #24646
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
P3
We're not considering working on this, but happy to review a PR. (No assignee)
team-Rules-API
API for writing rules/aspects: providers, runfiles, actions, artifacts
type: bug
Description of the bug:
When one runs
ctx.expand_location()
on the expression$(locations <a py_binary>)
for a custom rule, multiple files are returned.However, this is not the case for genrule's.
Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
BUILD
myrule.bzl
And create an empty
WORKSPACE
anda.py
file.With the above setup:
bazel build :gen
, it will printbazel-out/k8-opt-exec-2B5CBBC6/bin/a
, indicating that$(locations :a)
correctly resolved to the generated binary.bazel build :mytarget
, it will print./a.py bazel-out/k8-fastbuild/bin/a
, indicating that$(locations :a)
resolves to multiple files.I tried turning
tools
intodeps
for my:gen
target. Then,bazel build :gen
also prints two paths.I tried adding
cfg = "exec"
todeps
'sattr.label_list
, but the result is the same.This makes me unable to resolve to the correct binary to execute without some hacky code (e.g. CL)
How do I call ctx.expand_location so it produces the same output like genrule.tools does?
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 6.4.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
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
I don't think so.
Have you found anything relevant by searching the web?
https://stackoverflow.com/questions/57497270/bazel-how-to-run-py-binary-to-produce-input-files-before-testing
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: