12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- """Core rules for building Python projects.
16
-
17
- Currently the definitions here are re-exports of the native rules, "blessed" to
18
- work under `--incompatible_load_python_rules_from_bzl`. As the native rules get
19
- migrated to Starlark, their implementations will be moved here.
15
+ """
16
+ Core rules for building Python projects.
20
17
"""
21
18
22
19
load ("@bazel_tools//tools/python:srcs_version.bzl" , _find_requirements = "find_requirements" )
23
20
load ("@bazel_tools//tools/python:toolchain.bzl" , _py_runtime_pair = "py_runtime_pair" )
24
- load ("//python/private:reexports.bzl" , "internal_PyInfo" , "internal_PyRuntimeInfo" )
21
+ load (
22
+ "//python/private:reexports.bzl" ,
23
+ "internal_PyInfo" ,
24
+ "internal_PyRuntimeInfo" ,
25
+ _py_binary = "py_binary" ,
26
+ _py_library = "py_library" ,
27
+ _py_runtime = "py_runtime" ,
28
+ _py_test = "py_test" ,
29
+ )
25
30
26
31
# Exports of native-defined providers.
27
32
28
33
PyInfo = internal_PyInfo
29
34
30
35
PyRuntimeInfo = internal_PyRuntimeInfo
31
36
32
- # The implementation of the macros and tagging mechanism follows the example
33
- # set by rules_cc and rules_java.
34
-
35
- _MIGRATION_TAG = "__PYTHON_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
36
-
37
- def _add_tags (attrs ):
38
- if "tags" in attrs and attrs ["tags" ] != None :
39
- attrs ["tags" ] = attrs ["tags" ] + [_MIGRATION_TAG ]
40
- else :
41
- attrs ["tags" ] = [_MIGRATION_TAG ]
42
- return attrs
43
-
44
37
def _current_py_toolchain_impl (ctx ):
45
38
toolchain = ctx .toolchains [ctx .attr ._toolchain ]
46
39
@@ -84,36 +77,6 @@ current_py_toolchain = rule(
84
77
],
85
78
)
86
79
87
- def py_library (** attrs ):
88
- """See the Bazel core [py_library](https://docs.bazel.build/versions/master/be/python.html#py_library) documentation.
89
-
90
- Args:
91
- **attrs: Rule attributes
92
- """
93
-
94
- # buildifier: disable=native-python
95
- native .py_library (** _add_tags (attrs ))
96
-
97
- def py_binary (** attrs ):
98
- """See the Bazel core [py_binary](https://docs.bazel.build/versions/master/be/python.html#py_binary) documentation.
99
-
100
- Args:
101
- **attrs: Rule attributes
102
- """
103
-
104
- # buildifier: disable=native-python
105
- native .py_binary (** _add_tags (attrs ))
106
-
107
- def py_test (** attrs ):
108
- """See the Bazel core [py_test](https://docs.bazel.build/versions/master/be/python.html#py_test) documentation.
109
-
110
- Args:
111
- **attrs: Rule attributes
112
- """
113
-
114
- # buildifier: disable=native-python
115
- native .py_test (** _add_tags (attrs ))
116
-
117
80
def _py_import_impl (ctx ):
118
81
# See https://github.com/bazelbuild/bazel/blob/0.24.0/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java#L104 .
119
82
import_paths = [
@@ -164,18 +127,16 @@ py_import = rule(
164
127
},
165
128
)
166
129
167
- def py_runtime (** attrs ):
168
- """See the Bazel core [py_runtime](https://docs.bazel.build/versions/master/be/python.html#py_runtime) documentation.
169
-
170
- Args:
171
- **attrs: Rule attributes
172
- """
173
-
174
- # buildifier: disable=native-python
175
- native .py_runtime (** _add_tags (attrs ))
176
-
177
130
# Re-exports of Starlark-defined symbols in @bazel_tools//tools/python.
178
131
179
132
py_runtime_pair = _py_runtime_pair
180
133
181
134
find_requirements = _find_requirements
135
+
136
+ py_library = _py_library
137
+
138
+ py_binary = _py_binary
139
+
140
+ py_test = _py_test
141
+
142
+ py_runtime = _py_runtime
0 commit comments