@@ -10,21 +10,37 @@ Status: This is **ALPHA** software.
10
10
11
11
## Rules
12
12
13
- * [ pip_import] ( docs/python/pip.md#pip_import )
14
- * [ py_library] ( docs/python/python.md#py_library )
15
- * [ py_binary] ( docs/python/python.md#py_binary )
16
- * [ py_test] ( docs/python/python.md#py_test )
13
+ ### Core Python rules
14
+
15
+ * [ py_library] ( docs/python.md#py_library )
16
+ * [ py_binary] ( docs/python.md#py_binary )
17
+ * [ py_test] ( docs/python.md#py_test )
18
+ * [ py_runtime] ( docs/python.md#py_runtime )
19
+ * [ py_runtime_pair] ( docs/python.md#py_runtime_pair )
20
+
21
+ ### Packaging rules
22
+
23
+ * [ pip_import] ( docs/pip.md#pip_import )
17
24
18
25
## Overview
19
26
20
- This repository provides Python rules for Bazel. Currently, support for
21
- rules that are available from Bazel core are simple aliases to that bundled
22
- functionality. On top of that, this repository provides support for installing
23
- dependencies typically managed via ` pip ` .
27
+ This repository provides two sets of Python rules for Bazel. The core rules
28
+ provide the essential library, binary, test, and toolchain rules that are
29
+ expected for any language supported in Bazel. The packaging rules provide
30
+ support for integration with dependencies that, in a non-Bazel environment,
31
+ would typically be managed by ` pip ` .
32
+
33
+ Historically, the core rules have been bundled with Bazel itself. The Bazel
34
+ team is in the process of transitioning these rules to live in
35
+ bazelbuild/rules_python instead. In the meantime, all users of Python rules in
36
+ Bazel should migrate their builds to load these rules and their related symbols
37
+ (` PyInfo ` , etc.) from ` @rules_python ` instead of using built-ins or
38
+ ` @bazel_tools//tools/python ` .
24
39
25
40
## Setup
26
41
27
- Add the following to your ` WORKSPACE ` file to add the external repositories:
42
+ To use this repository, first modify your ` WORKSPACE ` file to load it and call
43
+ the initialization functions as needed:
28
44
29
45
``` python
30
46
load(" @bazel_tools//tools/build_defs/repo:git.bzl" , " git_repository" )
@@ -36,19 +52,19 @@ git_repository(
36
52
commit = " {HEAD} " ,
37
53
)
38
54
39
- # Only needed for PIP support:
40
- load(" @rules_python//python:pip.bzl" , " pip_repositories" )
55
+ # This call should always be present.
56
+ load(" @rules_python//python:repositories.bzl" , " py_repositories" )
57
+ py_repositories()
41
58
59
+ # This one is only needed if you're using the packaging rules.
60
+ load(" @rules_python//python:pip.bzl" , " pip_repositories" )
42
61
pip_repositories()
43
62
```
44
63
45
- Then in your ` BUILD ` files load the python rules with:
64
+ Then in your ` BUILD ` files, load the core rules as needed with:
46
65
47
66
``` python
48
- load(
49
- " @rules_python//python:defs.bzl" ,
50
- " py_binary" , " py_library" , " py_test" ,
51
- )
67
+ load(" @rules_python//python:defs.bzl" , " py_binary" )
52
68
53
69
py_binary(
54
70
name = " main" ,
@@ -118,18 +134,34 @@ format in the future.
118
134
https://packaging.python.org/tutorials/installing-packages/#installing-setuptools-extras )
119
135
will have a target of the extra name (in place of ` pkg ` above).
120
136
121
- ## Updating ` docs/ `
137
+ ## Development
138
+
139
+ ### Documentation
140
+
141
+ All of the content under ` docs/ ` besides the ` BUILD ` file is generated with
142
+ Stardoc. To regenerate the documentation, simply run
122
143
123
- All of the content (except ` BUILD ` ) under ` docs/ ` is generated. To update the
124
- documentation simply run this in the root of the repository:
125
144
``` shell
126
145
./update_docs.sh
127
146
```
128
147
129
- ## Updating ` tools/ `
148
+ from the repository root.
149
+
150
+ ### Precompiled par files
151
+
152
+ The ` piptool.par ` and ` whltool.par ` files underneath ` tools/ ` are compiled
153
+ versions of the Python scripts under the ` rules_python/ ` directory. We need to
154
+ check in built artifacts because they are executed during ` WORKSPACE `
155
+ evaluation, before Bazel itself is able to build anything from source.
156
+
157
+ The .par files need to be regenerated whenever their sources are updated. This
158
+ can be done by running
130
159
131
- All of the content (except ` BUILD ` ) under ` tools/ ` is generated. To update the
132
- documentation simply run this in the root of the repository:
133
160
``` shell
134
161
./update_tools.sh
135
162
```
163
+
164
+ from the repository root. However, since these files contain compiled code,
165
+ we do not accept commits that modify them from untrusted sources. If you submit
166
+ a pull request that modifies the sources and we accept the changes, we will
167
+ regenerate these files for you before merging.
0 commit comments