10000 Improve README documentation of pip_install rule [tiny] (#501) · lapointexavier/rules_python@9256757 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9256757

Browse files
author
Jonathon Belotti
authored
Improve README documentation of pip_install rule [tiny] (bazel-contrib#501)
1 parent 929d5a1 commit 9256757

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,39 +76,43 @@ py_binary(
7676

7777
## Using the packaging rules
7878

79-
The packaging rules create two kinds of repositories: A central repo that holds
80-
downloaded wheel files, and individual repos for each wheel's extracted
81-
contents. Users only need to interact with the central repo; the wheel repos
82-
are essentially an implementation detail. The central repo provides a
83-
`WORKSPACE` macro to create the wheel repos, as well as a function to call in
84-
`BUILD` files to translate a pip package name into the label of a `py_library`
79+
Usage of the packaging rules involves two main steps.
80+
81+
1. [Installing `pip` dependencies](#installing-pip-dependencies)
82+
2. [Consuming `pip` dependencies](#consuming-pip-dependencies)
83+
84+
The packaging rules create two kinds of repositories: A central external repo that holds
85+
downloaded wheel files, and individual external repos for each wheel's extracted
86+
contents. Users only need to interact with the central external repo; the wheel repos
87+
are essentially an implementation detail. The central external repo provides a
88+
`WORKSPACE` macro to create the wheel repos, as well as a function, `requirement()`, for use in
89+
`BUILD` files that translates a pip package name into the label of a `py_library`
8590
target in the appropriate wheel repo.
8691

87-
### Importing `pip` dependencies
92+
### Installing `pip` dependencies
8893

89-
To add pip dependencies to your `WORKSPACE` load
90-
the `pip_install` function, and call it to create the
91-
individual wheel repos.
94+
To add pip dependencies to your `WORKSPACE`, load the `pip_install` function, and call it to create the
95+
central external repo and individual wheel external repos.
9296

9397

9498
```python
9599
load("@rules_python//python:pip.bzl", "pip_install")
96100

97-
# Create a central repo that knows about the dependencies needed for
98-
# requirements.txt.
101+
# Create a central external repo, @my_deps, that contains Bazel targets for all the
102+
# third-party packages specified in the requirements.txt file.
99103
pip_install(
100104
name = "my_deps",
101105
requirements = "//path/to:requirements.txt",
102106
)
103107
```
104108

105-
Note that since pip is executed at WORKSPACE-evaluation time, Bazel has no
109+
Note that since `pip_install` is a repository rule and therefore executes pip at WORKSPACE-evaluation time, Bazel has no
106110
information about the Python toolchain and cannot enforce that the interpreter
107111
used to invoke pip matches the interpreter used to run `py_binary` targets. By
108112
default, `pip_install` uses the system command `"python3"`. This can be overridden by passing the
109113
`python_interpreter` attribute or `python_interpreter_target` attribute to `pip_install`.
110114

111-
You can have multiple `pip_install`s in the same workspace. This will create multiple central repos that have no relation to
115+
You can have multiple `pip_install`s in the same workspace. This will create multiple external repos that have no relation to
112116
one another, and may result in downloading the same wheels multiple times.
113117

114118
As with any repository rule, if you would like to ensure that `pip_install` is

0 commit comments

Comments
 (0)
0