You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: make readthedocs render a bit nicer and port docs over to Sphinx (bazel-contrib#1511)
This makes the Sphinx-based docs hosted on readthedocs render a bit more
nicely, fixes a few issues, and adds some features to //sphinxdocs
This also moves all the docs onto Sphinx, deleting the checked-in
documentation.
Doc fixes/improvements:
* Ports various docs over to Sphinx pages. They're split out from the
readme file.
* Version RTD is building is reflected in the docs
* Fixes some references to github files
* Includes the custom CSS file that styled the api docs
* Removes `-Q` from doc building; all warnings should be fixed now
* Added Bazel inventory file. Bazel doesn't provide one, but we can
manually provide on
and still use intersphinx functionality.
* Added `gh-path` custom role. This is a shortcut for writing the whole
github URL.
* Sets the primary domain to None. The default is py, which we don't use
much of, so it
just results in confusing crossref errors.
* Enable nitpicky mode to catch more errors.
* Remove the `starlark` marker from codeblocks; that name isn't
recognized by Sphinx.
The highlighting is still sufficient.
* Adds a glossary
Sphinxdocs improvements:
* Added a flag to pass along arbitrary `-D` args to the Sphinx
invocations. This allows
e.g., the `version` setting of the docs to be set on the command line
from the
`READTHEDOCS_VERSION` environment variable
* Added inventory file generation. These are files that allow
referencing external
projects using intersphinx.
* `sphinx_stardocs` have their public load path set as their page title.
This groups the
API docs more naturally by file. The path can be customized.
* `sphinx_stardocs` can have a footer specified for generated pages.
This allows easily
added a list of link labels for easy re-use.
* `readthedocs_install` now tries harder to find an open port
* The conf.py file is moved into the generated sources directly. This
was done because some
config settings are relative to the conf.py file, which was being placed
one directory
above the regular sources.
Fixesbazel-contrib#1484, bazel-contrib#1481
Examples live in the [examples](examples) directory.
@@ -25,356 +23,13 @@ rate, but this repository will still follow [semantic versioning](https://semver
25
23
26
24
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 [How to contribute](CONTRIBUTING.md) page for information on our development workflow.
27
25
26
+
## Documentation
27
+
28
+
For detailed documentation, see <https://rules-python.readthedocs.io>
29
+
28
30
## Bzlmod support
29
31
30
32
- Status: Beta
31
33
- Full Feature Parity: No
32
34
33
35
See [Bzlmod support](BZLMOD_SUPPORT.md) for more details.
34
-
35
-
## Getting started
36
-
37
-
The following two sections cover using `rules_python` with bzlmod and
38
-
the older way of configuring bazel with a `WORKSPACE` file.
39
-
40
-
### Using bzlmod
41
-
42
-
**IMPORTANT: bzlmod support is still in Beta; APIs are subject to change.**
43
-
44
-
The first step to using rules_python with bzlmod is to add the dependency to
45
-
your MODULE.bazel file:
46
-
47
-
```starlark
48
-
# Update the version "0.0.0" to the release found here:
After registration, your Python targets will use the toolchain's interpreter during execution, but a system-installed interpreter
193
-
is still used to 'bootstrap' Python targets (see https://github.com/bazelbuild/rules_python/issues/691).
194
-
You may also find some quirks while using this toolchain. Please refer to [python-build-standalone documentation's _Quirks_ section](https://python-build-standalone.readthedocs.io/en/latest/quirks.html).
195
-
196
-
### Toolchain usage in other rules
197
-
198
-
Python toolchains can be utilized in other bazel rules, such as `genrule()`, by adding the `toolchains=["@rules_python//python:current_py_toolchain"]` attribute. You can obtain the path to the Python interpreter using the `$(PYTHON2)` and `$(PYTHON3)`["Make" Variables](https://bazel.build/reference/be/make-variables). See the [`test_current_py_toolchain`](tests/load_from_macro/BUILD.bazel) target for an example.
199
-
200
-
### "Hello World"
201
-
202
-
Once you've imported the rule set into your `WORKSPACE` using any of these
203
-
methods, you can then load the core rules in your `BUILD` files with the following:
2.[Using third_party packages as dependencies](#using-third_party-packages-as-dependencies)
220
-
221
-
### Installing third_party packages
222
-
223
-
#### Using bzlmod
224
-
225
-
To add pip dependencies to your `MODULE.bazel` file, use the `pip.parse` extension, and call it to create the central external repo and individual wheel external repos. Include in the `MODULE.bazel` the toolchain extension as shown in the first bzlmod example above.
For more documentation, including how the rules can update/create a requirements file, see the bzlmod examples under the [examples](examples) folder.
237
-
238
-
#### Using a WORKSPACE file
239
-
240
-
To add pip dependencies to your `WORKSPACE`, load the `pip_parse` function and call it to create the central external repo and individual wheel external repos.
Note that since `pip_parse` is a repository rule and therefore executes pip at WORKSPACE-evaluation time, Bazel has no
260
-
information about the Python toolchain and cannot enforce that the interpreter
261
-
used to invoke pip matches the interpreter used to run `py_binary` targets. By
262
-
default, `pip_parse` uses the system command `"python3"`. To override this, pass in the
263
-
`python_interpreter` attribute or `python_interpreter_target` attribute to `pip_parse`.
264
-
265
-
You can have multiple `pip_parse`s in the same workspace. Or use the pip extension multiple times when using bzlmod.
266
-
This configuration will create multiple external repos that have no relation to one another
267
-
and may result in downloading the same wheels numerous times.
268
-
269
-
As with any repository rule, if you would like to ensure that `pip_parse` is
270
-
re-executed to pick up a non-hermetic change to your environment (e.g.,
271
-
updating your system `python` interpreter), you can force it to re-execute by running
272
-
`bazel sync --only [pip_parse name]`.
273
-
274
-
Note: The `pip_install` rule is deprecated. `pip_parse` offers identical functionality, and both `pip_install` and `pip_parse` now have the same implementation. The name `pip_install` may be removed in a future version of the rules.
275
-
276
-
The maintainers have made all reasonable efforts to facilitate a smooth transition. Still, some users of `pip_install` will need to replace their existing `requirements.txt` with a fully resolved set of dependencies using a tool such as `pip-tools` or the `compile_pip_requirements` repository rule.
277
-
278
-
### Using third_party packages as dependencies
279
-
280
-
Each extracted wheel repo contains a `py_library` target representing
281
-
the wheel's contents. There are two ways to access this library. The
282
-
first uses the `requirement()` function defined in the central
283
-
repo's `//:requirements.bzl` file. This function maps a pip package
Any 'extras' specified in the requirements lock file will be automatically added as transitive dependencies of the package. In the example above, you'd just put `requirement("useful_dep")`.
335
-
336
-
### Consuming Wheel Dists Directly
337
-
338
-
If you need to depend on the wheel dists themselves, for instance, to pass them
339
-
to some other packaging tool, you can get a handle to them with the `whl_requirement` macro. For example:
is a build file generator for Bazel projects. It can create new `BUILD.bazel` files for a project that follows language conventions and update existing build files to include new sources, dependencies, and options.
353
-
354
-
Bazel may run Gazelle using the Gazelle rule, or it may be installed and run as a command line tool.
355
-
356
-
See the documentation for Gazelle with rules_python [here](gazelle).
357
-
358
-
## Migrating from the bundled rules
359
-
360
-
The core rules are currently available in Bazel as built-in symbols, but this
361
-
form is deprecated. Instead, you should depend on rules_python in your
362
-
`WORKSPACE` file and load the Python rules from
363
-
`@rules_python//python:defs.bzl`.
364
-
365
-
A [buildifier](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md)
366
-
fix is available to automatically migrate `BUILD` and `.bzl` files to add the
367
-
appropriate `load()` statements and rewrite uses of `native.py_*`.
368
-
369
-
```sh
370
-
# Also consider using the -r flag to modify an entire workspace.
0 commit comments