11# Python Rules for Bazel
22
3- ` rules_python ` is the home for 4 major components:
4- * the core Python rules -- ` py_library ` , ` py_binary ` , ` py_test ` ,
5- ` py_proto_library ` , and related symbols that provide the basis for Python
6- support in Bazel.
3+ ` rules_python ` is the home for 4 major components with varying maturity levels.
74
8- This is subject to our breaking change policy outlined in the <support >.
9- * Package installation rules for integrating with PyPI and other SimpleAPI
10- complying indexes.
5+ :::{topic} Core rules
116
12- This is still ` experimental ` and the APIs might change more often than the
13- core rules or you may experience regressions between the minor releases. In
14- that case, please raise tickets to the GH issues bug tracker.
15- * ` sphinxdocs ` rules allowing users to generate documentation from bazel or
16- Python source code.
7+ The core Python rules -- ` py_library ` , ` py_binary ` , ` py_test ` ,
8+ ` py_proto_library ` , and related symbols that provide the basis for Python
9+ support in Bazel.
1710
18- This is available as is and without any guarantees. The semantic versioning
19- used by ` rules_python ` does not apply to bazel rules or the output.
20- * ` gazelle ` plugin for generating ` BUILD.bazel ` files based on Python source
21- code .
11+ When using bazel 6, the core rules built into the Bazel binary, and the symbols
12+ in this repository are simple aliases. On bazel 7 and above ` rules_python ` uses
13+ a separate Starlark implementation,
14+ see {ref} ` Migrating from the Bundled Rules ` below .
2215
23- This is available as is and without any guarantees. The semantic versioning
24- used by ` rules_python ` does not apply to the plugin.
16+ Once rules_python 1.0 is released, they will follow
17+ [ semantic versioning] ( https://semver.org ) and the breaking change policy
18+ outlined in the [ support] ( support ) page.
2519
26- Documentation for rules_python lives here and in the
27- [ Bazel Build Encyclopedia] ( https://docs.bazel.build/versions/master/be/python.html ) .
20+ :::
2821
29- Examples are in the {gh-path} ` examples ` directory.
22+ :::{topic} PyPI integration
3023
31- When using bazel 6, the core rules built into the Bazel binary, and the symbols
32- in this repository are simple aliases. However, on bazel 7 and above starlark
33- implementation in this repository is used.
34- See {ref}` Migrating from the Bundled Rules ` below.
24+ Package installation rules for integrating with PyPI and other SimpleAPI
25+ complying indexes.
26+
27+ These rules are still ` experimental ` and the APIs might change more often
28+ than the core rules or you may experience regressions between the minor
29+ releases. In that case, please raise tickets to the GH issues bug tracker.
30+
31+ :::
32+
33+ :::{topic} Sphinxdocs
34+
35+ ` sphinxdocs ` rules allowing users to generate documentation from bazel or
36+ Python source code.
37+
38+ This is available as is and the semantic versioning used by ` rules_python ` does
39+ not apply to bazel rules or the output.
40+
41+ :::
42+
43+ :::{topic} Gazelle plugin
3544
36- The core rules are stable. Their implementation in Bazel is subject to Bazel's
37- [ backward compatibility policy] ( https://docs.bazel.build/versions/master/backward-compatibility.html ) .
38- Once migrated to rules_python, they may evolve at a different
39- rate, but this repository will still follow [ semantic versioning] ( https://semver.org ) .
45+ ` gazelle ` plugin for generating ` BUILD.bazel ` files based on Python source
46+ code.
47+
48+ This is available as is and the semantic versioning used by ` rules_python ` does
49+ not apply to the plugin.
50+
51+ :::
4052
4153The Bazel community maintains this repository. Neither Google nor the Bazel
4254team provides support for the code. However, this repository is part of the
4355test suite used to vet new Bazel releases. See {gh-path}`How to contribute
4456<CONTRIBUTING.md>` for information on our development workflow.
4557
46- ## Bzlmod support
47-
48- - Status: GA
58+ ## Examples
4959
50- See {gh-path} ` Bzlmod support <BZLMOD_SUPPORT.md> ` for any behaviour differences between
51- ` bzlmod ` and ` WORKSPACE ` .
60+ This documentation is an example of ` sphinxdocs ` rules and the rest of the
61+ components have examples in the {gh-path} ` examples ` directory .
5262
5363## Migrating from the bundled rules
5464
5565The core rules are currently available in Bazel as built-in symbols, but this
5666form is deprecated. Instead, you should depend on rules_python in your
57- ` WORKSPACE ` file and load the Python rules from
58- ` @rules_python//python:defs.bzl ` .
67+ ` WORKSPACE ` or ` MODULE.bazel ` file and load the Python rules from
68+ ` @rules_python//python:defs.bzl ` or load paths described in the API documentation .
5969
6070A [ buildifier] ( https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md )
6171fix is available to automatically migrate ` BUILD ` and ` .bzl ` files to add the
@@ -66,13 +76,18 @@ appropriate `load()` statements and rewrite uses of `native.py_*`.
6676buildifier --lint=fix --warnings=native-py < files>
6777```
6878
69- Currently, the ` WORKSPACE ` file needs to be updated manually as per [ Getting
70- started] ( getting-started ) .
79+ Currently, the ` WORKSPACE ` file needs to be updated manually as per
80+ [ Getting started] ( getting-started ) .
7181
7282Note that Starlark-defined bundled symbols underneath
7383` @bazel_tools//tools/python ` are also deprecated. These are not yet rewritten
7484by buildifier.
7585
86+ ## Migrating to bzlmod
87+
88+ See {gh-path}` Bzlmod support <BZLMOD_SUPPORT.md> ` for any behaviour differences between
89+ ` bzlmod ` and ` WORKSPACE ` .
90+
7691
7792``` {toctree}
7893:hidden:
0 commit comments