diff --git a/examples/bzlmod/.bazelignore b/examples/bzlmod/.bazelignore index 536ded93a6..a59e740c96 100644 --- a/examples/bzlmod/.bazelignore +++ b/examples/bzlmod/.bazelignore @@ -1,3 +1,2 @@ other_module -py_proto_library/foo_external vendor diff --git a/examples/bzlmod/MODULE.bazel b/examples/bzlmod/MODULE.bazel index 14c490cb0d..5c71d32421 100644 --- a/examples/bzlmod/MODULE.bazel +++ b/examples/bzlmod/MODULE.bazel @@ -12,9 +12,6 @@ local_path_override( path = "../..", ) -# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc) -bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf") - # Only needed to make rules_python's CI happy. rules_java 8.3.0+ is needed so # that --java_runtime_version=remotejdk_11 works with Bazel 8. bazel_dep(name = "rules_java", version = "8.16.1") @@ -291,11 +288,5 @@ local_path_override( path = "other_module", ) -bazel_dep(name = "foo_external", version = "") -local_path_override( - module_name = "foo_external", - path = "py_proto_library/foo_external", -) - # example test dependencies bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True) diff --git a/examples/bzlmod/py_proto_library/BUILD.bazel b/examples/bzlmod/py_proto_library/BUILD.bazel deleted file mode 100644 index daea410365..0000000000 --- a/examples/bzlmod/py_proto_library/BUILD.bazel +++ /dev/null @@ -1,35 +0,0 @@ -load("@bazel_skylib//rules:native_binary.bzl", "native_test") -load("@rules_python//python:py_test.bzl", "py_test") - -py_test( - name = "pricetag_test", - srcs = ["test.py"], - main = "test.py", - deps = [ - "//py_proto_library/example.com/proto:pricetag_py_pb2", - ], -) - -py_test( - name = "message_test", - srcs = ["message_test.py"], - deps = [ - "//py_proto_library/example.com/another_proto:message_py_pb2", - ], -) - -# Regression test for https://github.com/bazel-contrib/rules_python/issues/2515 -# -# This test fails before protobuf 30.0 release -# when ran with --legacy_external_runfiles=False (default in Bazel 8.0.0). -native_test( - name = "external_import_test", - src = "@foo_external//:py_binary_with_proto", - tags = ["manual"], # TODO: reenable when com_google_protobuf is upgraded - # Incompatible with Windows: native_test wrapping a py_binary doesn't work - # on Windows. - target_compatible_with = select({ - "@platforms//os:windows": ["@platforms//:incompatible"], - "//conditions:default": [], - }), -) diff --git a/examples/bzlmod/py_proto_library/example.com/another_proto/BUILD.bazel b/examples/bzlmod/py_proto_library/example.com/another_proto/BUILD.bazel deleted file mode 100644 index 29f08c21ca..0000000000 --- a/examples/bzlmod/py_proto_library/example.com/another_proto/BUILD.bazel +++ /dev/null @@ -1,16 +0,0 @@ -load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") -load("@rules_python//python:proto.bzl", "py_proto_library") - -py_proto_library( - name = "message_py_pb2", - visibility = ["//visibility:public"], - deps = [":message_proto"], -) - -proto_library( - name = "message_proto", - srcs = ["message.proto"], - # https://bazel.build/reference/be/protocol-buffer#proto_library.strip_import_prefix - strip_import_prefix = "/py_proto_library/example.com", - deps = ["//py_proto_library/example.com/proto:pricetag_proto"], -) diff --git a/examples/bzlmod/py_proto_library/example.com/another_proto/message.proto b/examples/bzlmod/py_proto_library/example.com/another_proto/message.proto deleted file mode 100644 index 6e7dcc5793..0000000000 --- a/examples/bzlmod/py_proto_library/example.com/another_proto/message.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -package rules_python; - -import "proto/pricetag.proto"; - -message TestMessage { - uint32 index = 1; - PriceTag pricetag = 2; -} diff --git a/examples/bzlmod/py_proto_library/example.com/proto/BUILD.bazel b/examples/bzlmod/py_proto_library/example.com/proto/BUILD.bazel deleted file mode 100644 index 1f8e8f2818..0000000000 --- a/examples/bzlmod/py_proto_library/example.com/proto/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") -load("@rules_python//python:proto.bzl", "py_proto_library") - -py_proto_library( - name = "pricetag_py_pb2", - visibility = ["//visibility:public"], - deps = [":pricetag_proto"], -) - -proto_library( - name = "pricetag_proto", - srcs = ["pricetag.proto"], - # https://bazel.build/reference/be/protocol-buffer#proto_library.strip_import_prefix - strip_import_prefix = "/py_proto_library/example.com", - visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:any_proto"], -) diff --git a/examples/bzlmod/py_proto_library/example.com/proto/pricetag.proto b/examples/bzlmod/py_proto_library/example.com/proto/pricetag.proto deleted file mode 100644 index 3fa68de84b..0000000000 --- a/examples/bzlmod/py_proto_library/example.com/proto/pricetag.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; - -import "google/protobuf/any.proto"; - -package rules_python; - -message PriceTag { - string name = 2; - double cost = 1; - google.protobuf.Any metadata = 3; -} diff --git a/examples/bzlmod/py_proto_library/foo_external/BUILD.bazel b/examples/bzlmod/py_proto_library/foo_external/BUILD.bazel deleted file mode 100644 index 183a3c28d2..0000000000 --- a/examples/bzlmod/py_proto_library/foo_external/BUILD.bazel +++ /dev/null @@ -1,22 +0,0 @@ -load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") -load("@com_google_protobuf//bazel:py_proto_library.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"], -) diff --git a/examples/bzlmod/py_proto_library/foo_external/MODULE.bazel b/examples/bzlmod/py_proto_library/foo_external/MODULE.bazel deleted file mode 100644 index aca6f98eab..0000000000 --- a/examples/bzlmod/py_proto_library/foo_external/MODULE.bazel +++ /dev/null @@ -1,7 +0,0 @@ -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") diff --git a/examples/bzlmod/py_proto_library/foo_external/WORKSPACE b/examples/bzlmod/py_proto_library/foo_external/WORKSPACE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/bzlmod/py_proto_library/foo_external/nested/foo/my_proto.proto b/examples/bzlmod/py_proto_library/foo_external/nested/foo/my_proto.proto deleted file mode 100644 index 7b8440cbed..0000000000 --- a/examples/bzlmod/py_proto_library/foo_external/nested/foo/my_proto.proto +++ /dev/null @@ -1,6 +0,0 @@ -syntax = "proto3"; - -package my_proto; - -message MyMessage { -} diff --git a/examples/bzlmod/py_proto_library/foo_external/py_binary_with_proto.py b/examples/bzlmod/py_proto_library/foo_external/py_binary_with_proto.py deleted file mode 100644 index 67e798bb8f..0000000000 --- a/examples/bzlmod/py_proto_library/foo_external/py_binary_with_proto.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys - -if __name__ == "__main__": - import my_proto_pb2 - - sys.exit(0) diff --git a/examples/bzlmod/py_proto_library/message_test.py b/examples/bzlmod/py_proto_library/message_test.py deleted file mode 100644 index b1a6942a54..0000000000 --- a/examples/bzlmod/py_proto_library/message_test.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -import unittest - -from another_proto import message_pb2 - - -class TestCase(unittest.TestCase): - def test_message(self): - got = message_pb2.TestMessage( - index=5, - ) - self.assertIsNotNone(got) - - -if __name__ == "__main__": - sys.exit(unittest.main()) diff --git a/examples/bzlmod/py_proto_library/test.py b/examples/bzlmod/py_proto_library/test.py deleted file mode 100644 index 24ab8ddc70..0000000000 --- a/examples/bzlmod/py_proto_library/test.py +++ /dev/null @@ -1,21 +0,0 @@ -import json -import unittest - -from proto import pricetag_pb2 - - -class TestCase(unittest.TestCase): - def test_pricetag(self): - got = pricetag_pb2.PriceTag( - name="dollar", - cost=5.00, - ) - - metadata = {"description": "some text..."} - got.metadata.value = json.dumps(metadata).encode("utf-8") - - self.assertIsNotNone(got) - - -if __name__ == "__main__": - unittest.main()