-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: py_proto_library: external runfiles
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. Fixes #2515. Added a regression test, and tested locally against the minimal reproducer in that issue.
- Loading branch information
Showing
8 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
load("@rules_python//python:proto.bzl", "py_proto_library") | ||
load("@rules_python//python:py_binary.bzl", "py_binary") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
proto_library( | ||
name = "proto_lib", | ||
srcs = ["nested/foo/my_proto.proto"], | ||
strip_import_prefix = "/nested/foo", | ||
) | ||
|
||
py_proto_library( | ||
name = "a_proto", | ||
deps = [":proto_lib"], | ||
) | ||
|
||
py_binary( | ||
name = "py_binary_with_proto", | ||
srcs = ["py_binary_with_proto.py"], | ||
deps = [":a_proto"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module( | ||
name = "foo_external", | ||
version = "0.0.1", | ||
) | ||
|
||
bazel_dep(name = "rules_python", version = "1.0.0") | ||
bazel_dep(name = "protobuf", version = "28.2", repo_name = "com_google_protobuf") | ||
bazel_dep(name = "rules_proto", version = "7.0.2") |
6 changes: 6 additions & 0 deletions
6
examples/bzlmod/py_proto_library/foo_external/nested/foo/my_proto.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
syntax = "proto3"; | ||
|
||
package my_proto; | ||
|
||
message MyMessage { | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/bzlmod/py_proto_library/foo_external/py_binary_with_proto.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
import my_proto_pb2 | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters