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
- Updated primary README.md to include documentation for using bzlmod or
a WORKSPACE file.
- Updated gazelle/README.md to include documentation for only using
bzlmod and provided a link to the older docs.
- Included other general updates for the gazelle documentation.
Copy file name to clipboardExpand all lines: README.md
+61-3Lines changed: 61 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,47 @@ contribute](CONTRIBUTING.md) page for information on our development workflow.
33
33
34
34
## Getting started
35
35
36
+
The next two sections cover using `rules_python` with bzlmod and
37
+
the older way of configuring bazel with a `WORKSPACE` file.
38
+
39
+
### Using bzlmod
40
+
41
+
To import rules_python in your project, you first need to add it to your
42
+
`MODULES.bazel` file, using the snippet provided in the
43
+
[release you choose](https://github.com/bazelbuild/rules_python/releases).
44
+
45
+
#### Toolchain registration with bzlmod
46
+
47
+
To register a hermetic Python toolchain rather than rely on a system-installed interpreter for runtime execution, you can add to the `MODULES.bazel` file:
48
+
49
+
```python
50
+
# Find the latest version number here: https://github.com/bazelbuild/rules_python/releases
51
+
# and change the version number if needed in the line below.
52
+
bazel_dep(name="rules_python", version="0.20.0")
53
+
54
+
# You do not have to use pip for the toolchain, but most people
Note that since `pip_parse` is a repository rule and therefore executes pip at WORKSPACE-evaluation time, Bazel has no
141
200
information about the Python toolchain and cannot enforce that the interpreter
142
201
used to invoke pip matches the interpreter used to run `py_binary` targets. By
143
202
default, `pip_parse` uses the system command `"python3"`. This can be overridden by passing the
144
203
`python_interpreter` attribute or `python_interpreter_target` attribute to `pip_parse`.
145
204
146
-
You can have multiple `pip_parse`s in the same workspace. This will create multiple external repos that have no relation to
147
-
one another, and may result in downloading the same wheels multiple times.
205
+
You can have multiple `pip_parse`s in the same workspace. This will create multiple external repos that have no relation to one another, and may result in downloading the same wheels multiple times.
148
206
149
207
As with any repository rule, if you would like to ensure that `pip_parse` is
150
208
re-executed in order to pick up a non-hermetic change to your environment (e.g.,
is a build file generator for Bazel projects. It can create new BUILD.bazel files for a project that follows language conventions, and it can update existing build files to include new sources, dependencies, and options.
5
+
6
+
Gazelle may be run by Bazel using the gazelle rule, or it may be installed and run as a command line tool.
0 commit comments