File tree 15 files changed +101
-2
lines changed
15 files changed +101
-2
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,16 @@ new_local_repository(
79
79
path = "./third_party/protobuf/3.6.1/" ,
80
80
)
81
81
82
+ # This is a mock version of bazelbuild/rules_python that contains only
83
+ # @rules_python//python:defs.bzl. It is used by protobuf.
84
+ # TODO(#9029): We could potentially replace this with the real @rules_python.
85
+ new_local_repository (
86
+ name = "rules_python" ,
87
+ path = "./third_party/rules_python" ,
88
+ build_file = "//third_party/rules_python:BUILD" ,
89
+ workspace_file = "//third_party/rules_python:rules_python.WORKSPACE" ,
90
+ )
91
+
82
92
local_repository (
83
93
name = "googleapis" ,
84
94
path = "./third_party/googleapis/" ,
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ filegroup(
35
35
"//third_party/py/gflags:srcs" ,
36
36
"//third_party/py/mock:srcs" ,
37
37
"//third_party/py/six:srcs" ,
38
+ "//third_party/rules_python:srcs" ,
38
39
"//third_party/zlib:srcs" ,
39
40
"//third_party/nanopb:srcs" ,
40
41
"//third_party/def_parser:srcs" ,
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. Consider replacing label with @rules_python as per #9029 if
2
+ # merging from upstream becomes an issue.
3
+ load ("//tools/python:private/defs.bzl" , "py_test" )
4
+
1
5
licenses (["notice" ]) # 3-clause BSD
2
6
3
7
package (
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ config_setting(
21
21
22
22
load (":protobuf.bzl" , "py_proto_library" )
23
23
load (":compiler_config_setting.bzl" , "create_compiler_config_setting" )
24
+ # Needed for #9006. Hopefully a future upstream version will include this line.
25
+ load ("@rules_python//python:defs.bzl" , "py_library" )
24
26
25
27
filegroup (
26
28
name = "srcs" ,
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. Hopefully a future upstream version will include this line.
2
+ load ("@rules_python//python:defs.bzl" , "py_library" , "py_test" )
3
+
1
4
def _GetPath (ctx , path ):
2
5
if ctx .label .workspace_root :
3
6
return ctx .label .workspace_root + "/" + path
@@ -383,7 +386,7 @@ def py_proto_library(
383
386
if default_runtime and not default_runtime in py_libs + deps :
384
387
py_libs = py_libs + [default_runtime ]
385
388
386
- native . py_library (
389
+ py_library (
387
390
name = name ,
388
391
srcs = outs + py_extra_srcs ,
389
392
deps = py_libs + deps ,
@@ -406,7 +409,7 @@ def internal_protobuf_py_tests(
406
409
"""
407
410
for m in modules :
408
411
s = "python/google/protobuf/internal/%s.py" % m
409
- native . py_test (
412
+ py_test (
410
413
name = "py_%s" % m ,
411
414
srcs = [s ],
412
415
main = s ,
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ You will create and merge the following Pull Requests.
43
43
copy the `licenses` declaration and the `srcs` filegroup to the corresponding file under
44
44
`third_party/protobuf/<new_proto>`.
45
45
46
+ 1. Modify the new protobuf to be compatible with #9006 (until upstream protobuf migrates):
47
+ In `third_party/protobuf/<new_proto>/BUILD` and `third_party/protobuf/<new_proto>/protobuf.bzl`,
48
+ copy the line that loads from `@rules_python` along with its explanatory comment, from the
49
+ corresponding files in the old proto directory. (See also #9019.)
50
+
46
51
1. In `third_party/protobuf/<new_proto>/BUILD`, in the `srcs` filegroup rule, update the version
47
52
number referring to the newly added `srcs` rules.
48
53
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. Consider replacing label with @rules_python as per #9029 if
2
+ # merging from upstream becomes an issue.
3
+ load ("//tools/python:private/defs.bzl" , "py_library" )
4
+
1
5
licenses (["notice" ])
2
6
3
7
filegroup (
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. Consider replacing label with @rules_python as per #9029 if
2
+ # merging from upstream becomes an issue.
3
+ load ("//tools/python:private/defs.bzl" , "py_library" )
4
+
1
5
licenses (["notice" ])
2
6
3
7
filegroup (
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. Consider replacing label with @rules_python as per #9029 if
2
+ # merging from upstream becomes an issue.
3
+ load ("//tools/python:private/defs.bzl" , "py_library" )
4
+
1
5
licenses (["notice" ])
2
6
3
7
filegroup (
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. Consider replacing label with @rules_python as per #9029 if
2
+ # merging from upstream becomes an issue.
3
+ load ("//tools/python:private/defs.bzl" , "py_library" )
4
+
1
5
licenses (["notice" ])
2
6
3
7
filegroup (
Original file line number Diff line number Diff line change
1
+ # Needed for #9006. We can't easily replace this label with a @rules_python
2
+ # label (#9029) because this file is used in both @io_bazel and @bazel_tools,
3
+ # the latter of which can't reference other repos.
4
+ load ("//tools/python:private/defs.bzl" , "py_library" )
5
+
1
6
licenses (["notice" ])
2
7
3
8
filegroup (
Original file line number Diff line number Diff line change
1
+ filegroup (
2
+ name = "srcs" ,
3
+ srcs = glob (["**" ]) + ["//third_party/rules_python/python:srcs" ],
4
+ visibility = ["//visibility:public" ],
5
+ )
Original file line number Diff line number Diff line change
1
+ filegroup (
2
+ name = "srcs" ,
3
+ srcs = glob (["**" ]),
4
+ visibility = ["//visibility:public" ],
5
+ )
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 The Bazel Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """This file is selectively copied from //tools/python:private/defs.bzl."""
16
+
17
+ _MIGRATION_TAG = "__PYTHON_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
18
+
19
+ def _add_tags (attrs ):
20
+ if "tags" in attrs and attrs ["tags" ] != None :
21
+ attrs ["tags" ] += [_MIGRATION_TAG ]
22
+ else :
23
+ attrs ["tags" ] = [_MIGRATION_TAG ]
24
+ return attrs
25
+
26
+ def py_library (** attrs ):
27
+ native .py_library (** _add_tags (attrs ))
28
+
29
+ def py_binary (** attrs ):
30
+ native .py_binary (** _add_tags (attrs ))
31
+
32
+ def py_test (** attrs ):
33
+ native .py_test (** _add_tags (attrs ))
34
+
35
+ def py_runtime (** attrs ):
36
+ native .py_runtime (** _add_tags (attrs ))
Original file line number Diff line number Diff line change
1
+ # A stub version of bazelbuild/rules_python that contains only the defs.bzl
2
+ # file, which is needed to access native Python rules under
3
+ # --incompatible_load_python_rules_from_bzl (#9006).
4
+ #
5
+ # TODO(#9029): Maybe replace this with the real thing.
6
+
7
+ workspace(name = "rules_python")
You can’t perform that action at this time.
0 commit comments