Skip to content

Commit

Permalink
py_proto_library: external runfiles fix
Browse files Browse the repository at this point in the history
Previously, the import path within the runfiles was only correct for the case `--legacy_external_runfiles=True` (which copied the runfiles into `$RUNFILES/<main repo>/external/<external repo>/<path>` in addition to `$RUNFILES/<external repo>/<path>`. This flag was flipped to False in Bazel 8.0.0.

This is identical to the change made to rules_python in bazelbuild/rules_python#2516.

Work towards bazelbuild/rules_python#2581.

PiperOrigin-RevId: 721941173
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Feb 1, 2025
1 parent 9a03332 commit fd22161
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bazel/py_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ def _py_proto_aspect_impl(target, ctx):
proto_root = proto_root[len(ctx.bin_dir.path) + 1:]

plugin_output = ctx.bin_dir.path + "/" + proto_root
proto_root = ctx.workspace_name + "/" + proto_root

# Import path within the runfiles tree
if proto_root.startswith("external/"):
proto_root = proto_root[len("external") + 1:]
else:
proto_root = ctx.workspace_name + "/" + proto_root

proto_common.compile(
actions = ctx.actions,
Expand Down

0 comments on commit fd22161

Please sign in to comment.