Skip to content

Commit c8d66a0

Browse files
committed
docs: rules_python bzlmod GA and 1.0 prep
This is documenting the current state and closing the last remaining TODO items for 1.0 release. Work towards bazel-contrib#1361.
1 parent 0e604b0 commit c8d66a0

File tree

2 files changed

+59
-24
lines changed

2 files changed

+59
-24
lines changed

BZLMOD_SUPPORT.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
## `rules_python` `bzlmod` support
44

5-
- Status: Beta
5+
- Status: GA
66
- Full Feature Parity: No
7+
- `rules_python`: Yes
8+
- `rules_python_gazelle_plugin`: No (see below).
79

8-
Some features are missing or broken, and the public APIs are not yet stable.
10+
In general `bzlmod` has more features than `WORKSPACE` and users are encouraged to migrate.
911

1012
## Configuration
1113

@@ -27,15 +29,6 @@ A user does not use `local_path_override` stanza and would define the version in
2729

2830
A second example, in [examples/bzlmod_build_file_generation](examples/bzlmod_build_file_generation) demonstrates the use of `bzlmod` to configure `gazelle` support for `rules_python`.
2931

30-
## Feature parity
31-
32-
This rule set does not have full feature partity with the older `WORKSPACE` type configuration:
33-
34-
1. Gazelle does not support finding deps in sub-modules. For instance we can have a dep like ` "@our_other_module//other_module/pkg:lib",` in a `py_test` definition.
35-
2. We have some features that are still not fully flushed out, and the user interface may change.
36-
37-
Check ["issues"](/bazelbuild/rules_python/issues) for an up to date list.
38-
3932
## Differences in behavior from WORKSPACE
4033

4134
### Default toolchain is not the local system Python
@@ -52,10 +45,30 @@ platforms.
5245
If you want to use the same toolchain as what WORKSPACE used, then manually
5346
register the builtin Bazel Python toolchain by doing
5447
`register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")`.
55-
**IMPORTANT: this should only be done in a root module, and may intefere with
48+
**IMPORTANT: this should only be done in a root module, and may interfere with
5649
the toolchains rules_python registers**.
5750

5851
NOTE: Regardless of your toolchain, due to
5952
[#691](https://github.com/bazelbuild/rules_python/issues/691), `rules_python`
6053
still relies on a local Python being available to bootstrap the program before
61-
handing over execution to the toolchain Python.
54+
handing over execution to the toolchain Python. To override this behaviour see
55+
{obj}`--bootstrap_impl=script`, which switches to `bash`-based bootstrap on
56+
UNIX systems.
57+
58+
### Better PyPI package downloading on bzlmod
59+
60+
On `bzlmod` users have the option to use the `bazel_downloader` to download packages
61+
and work correctly when `host` platform is not the same as the `target` platform. This
62+
provides faster package download times and integration with the credentials helper.
63+
64+
### Extra targets in `whl_library` repos
65+
66+
Due to how `bzlmod` is designed and the visibility rules that it enforces, it is best to use
67+
the targets in the `whl` repos as they are and not rely on using the `annotations` API to
68+
add extra targets to so-called `spoke` repos. For alternatives that should cover most of the
69+
existing usecases please see:
70+
* {bzl:obj}`py_console_script_binary` to create `entry_point` targets.
71+
* {bzl:obj}`whl_filegroup` to extract filegroups from the `whl` targets (e.g. `@pip//numpy:whl`)
72+
* {bzl:obj}`pip.override` to patch the downloaded `whl` files. Using that you
73+
can change the `METADATA` of the `whl` file that will influence how
74+
`rules_python` code generation behaves.

docs/index.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,54 @@
11
# Python Rules for Bazel
22

3-
rules_python is the home of the core Python rules -- `py_library`,
4-
`py_binary`, `py_test`, `py_proto_library`, and related symbols that provide the basis for Python
5-
support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
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.
7+
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.
11+
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.
17+
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.
22+
23+
This is available as is and without any guarantees. The semantic versioning
24+
used by `rules_python` does not apply to the plugin.
625

726
Documentation for rules_python lives here and in the
827
[Bazel Build Encyclopedia](https://docs.bazel.build/versions/master/be/python.html).
928

1029
Examples are in the {gh-path}`examples` directory.
1130

12-
Currently, the core rules build into the Bazel binary, and the symbols in this
13-
repository are simple aliases. However, we are migrating the rules to Starlark and removing them from the Bazel binary. Therefore, the future-proof way to depend on Python rules is via this repository. See
14-
{ref}`Migrating from the Bundled Rules` below.
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.
1535

1636
The core rules are stable. Their implementation in Bazel is subject to Bazel's
1737
[backward compatibility policy](https://docs.bazel.build/versions/master/backward-compatibility.html).
1838
Once migrated to rules_python, they may evolve at a different
1939
rate, but this repository will still follow [semantic versioning](https://semver.org).
2040

21-
The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See
22-
{gh-path}`How to contribute <CONTRIBUTING.md>` for information on our development workflow.
41+
The Bazel community maintains this repository. Neither Google nor the Bazel
42+
team provides support for the code. However, this repository is part of the
43+
test suite used to vet new Bazel releases. See {gh-path}`How to contribute
44+
<CONTRIBUTING.md>` for information on our development workflow.
2345

2446
## Bzlmod support
2547

26-
- Status: Beta
27-
- Full Feature Parity: No
48+
- Status: GA
2849

29-
See {gh-path}`Bzlmod support <BZLMOD_SUPPORT.md>` for more details
50+
See {gh-path}`Bzlmod support <BZLMOD_SUPPORT.md>` for any behaviour differences between
51+
`bzlmod` and `WORKSPACE`.
3052

3153
## Migrating from the bundled rules
3254

0 commit comments

Comments
 (0)