Skip to content

Commit 9afbefc

Browse files
py_proto_library: fix for --legacy_external_runfiles=True
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 bazel-contrib/rules_python#2516. Work towards bazel-contrib/rules_python#2581. PiperOrigin-RevId: 721941173
1 parent 9a03332 commit 9afbefc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bazel/py_proto_library.bzl

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ def _py_proto_aspect_impl(target, ctx):
7676
proto_root = proto_root[len(ctx.bin_dir.path) + 1:]
7777

7878
plugin_output = ctx.bin_dir.path + "/" + proto_root
79-
proto_root = ctx.workspace_name + "/" + proto_root
79+
80+
# Import path within the runfiles tree
81+
if proto_root.startswith("external/"):
82+
proto_root = proto_root[len("external") + 1:]
83+
else:
84+
proto_root = ctx.workspace_name + "/" + proto_root
8085

8186
proto_common.compile(
8287
actions = ctx.actions,

0 commit comments

Comments
 (0)