Skip to content

Commit d2d6ff5

Browse files
Yannicacozzette
authored andcommitted
[bazel] Load python rules from @rules_python
1 parent 479ba82 commit d2d6ff5

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library")
44
load("@rules_java//java:defs.bzl", "java_library")
55
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
6+
load("@rules_python//python:defs.bzl", "py_library")
67

78
licenses(["notice"])
89

WORKSPACE

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ local_repository(
55
path = "examples",
66
)
77

8+
local_repository(
9+
name = "submodule_gmock",
10+
path = "third_party/googletest",
11+
)
12+
813
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
914
load("//:protobuf_deps.bzl", "protobuf_deps")
1015

1116
# Load common dependencies.
1217
protobuf_deps()
1318

14-
new_local_repository(
15-
name = "submodule_gmock",
16-
build_file = "@//:third_party/googletest/BUILD.bazel",
17-
path = "third_party/googletest",
18-
)
19-
2019
http_archive(
2120
name = "six",
2221
build_file = "@//:six.BUILD",

examples/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# the WORKSPACE file in the same directory with this BUILD file for an
55
# example.
66

7-
load("@rules_proto//proto:defs.bzl", "proto_library")
8-
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
97
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
8+
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
9+
load("@rules_proto//proto:defs.bzl", "proto_library")
1010

1111
# For each .proto file, a proto_library target should be defined. This target
1212
# is not bound to any particular language. Instead, it defines the dependency

protobuf.bzl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
load("@rules_cc//cc:defs.bzl", "cc_library")
21
load("@bazel_skylib//lib:versions.bzl", "versions")
2+
load("@rules_cc//cc:defs.bzl", "cc_library")
3+
load("@rules_python//python:defs.bzl", "py_library", "py_test")
34

45
def _GetPath(ctx, path):
56
if ctx.label.workspace_root:
@@ -434,8 +435,7 @@ def py_proto_library(
434435

435436
if default_runtime and not default_runtime in py_libs + deps:
436437
py_libs = py_libs + [default_runtime]
437-
438-
native.py_library(
438+
py_library(
439439
name = name,
440440
srcs = outs + py_extra_srcs,
441441
deps = py_libs + deps,
@@ -458,7 +458,7 @@ def internal_protobuf_py_tests(
458458
"""
459459
for m in modules:
460460
s = "python/google/protobuf/internal/%s.py" % m
461-
native.py_test(
461+
py_test(
462462
name = "py_%s" % m,
463463
srcs = [s],
464464
main = s,

protobuf_deps.bzl

+11-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ def protobuf_deps():
4949
if not native.existing_rule("rules_proto"):
5050
http_archive(
5151
name = "rules_proto",
52-
sha256 = "88b0a90433866b44bb4450d4c30bc5738b8c4f9c9ba14e9661deb123f56a833d",
53-
strip_prefix = "rules_proto-b0cc14be5da05168b01db282fe93bdf17aa2b9f4",
54-
urls = ["https://github.com/bazelbuild/rules_proto/archive/b0cc14be5da05168b01db282fe93bdf17aa2b9f4.tar.gz"],
52+
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
53+
strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313",
54+
urls = ["https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz"],
55+
)
56+
57+
if not native.existing_rule("rules_python"):
58+
http_archive(
59+
name = "rules_python",
60+
sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6",
61+
strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27",
62+
urls = ["https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz"],
5563
)

0 commit comments

Comments
 (0)