@@ -20,17 +20,19 @@ load("//python/pip_install:requirements.bzl", _compile_pip_requirements = "compi
20
20
compile_pip_requirements = _compile_pip_requirements
21
21
22
22
def pip_install (requirements , name = "pip" , ** kwargs ):
23
- """Imports a `requirements.txt` file and generates a new `requirements.bzl` file .
23
+ """Accepts a `requirements.txt` file and installs the dependencies listed within .
24
24
25
- This is used via the `WORKSPACE` pattern:
25
+ Those dependencies become available in a generated `requirements.bzl` file.
26
+
27
+ This macro runs a repository rule that invokes `pip`. In your WORKSPACE file:
26
28
27
29
```python
28
30
pip_install(
29
31
requirements = ":requirements.txt",
30
32
)
31
33
```
32
34
33
- You can then reference imported dependencies from your `BUILD` file with:
35
+ You can then reference installed dependencies from a `BUILD` file with:
34
36
35
37
```python
36
38
load("@pip//:requirements.bzl", "requirement")
@@ -45,9 +47,16 @@ def pip_install(requirements, name = "pip", **kwargs):
45
47
)
46
48
```
47
49
48
- In addition to the `requirement` macro, which is used to access the generated `py_library`
49
- target generated from a package's wheel, The generated `requirements.bzl` file contains
50
- functionality for exposing [entry points][whl_ep] as `py_binary` targets as well.
50
+ > Note that this convenience comes with a cost.
51
+ > Analysis of any BUILD file which loads the requirements helper in this way will
52
+ > cause an eager-fetch of all the pip dependencies,
53
+ > even if no python targets are requested to be built.
54
+ > In a multi-language repo, this may cause developers to fetch dependencies they don't need,
55
+ > so consider using the long form for dependencies if this happens.
56
+
57
+ In addition to the `requirement` macro, which is used to access the `py_library`
58
+ target generated from a package's wheel, the generated `requirements.bzl` file contains
59
+ functionality for exposing [entry points][whl_ep] as `py_binary` targets.
51
60
52
61
[whl_ep]: https://packaging.python.org/specifications/entry-points/
53
62
@@ -63,7 +72,7 @@ def pip_install(requirements, name = "pip", **kwargs):
63
72
)
64
73
```
65
74
66
- Note that for packages who's name and script are the same, only the name of the package
75
+ Note that for packages whose name and script are the same, only the name of the package
67
76
is needed when calling the `entry_point` macro.
68
77
69
78
```python
@@ -76,9 +85,9 @@ def pip_install(requirements, name = "pip", **kwargs):
76
85
```
77
86
78
87
Args:
79
- requirements: A 'requirements.txt' pip requirements file.
80
- name: A unique name for the created external repository (default 'pip').
81
- **kwargs: Keyword arguments passed directly to the `pip_repository` repository rule.
88
+ requirements (Label) : A 'requirements.txt' pip requirements file.
89
+ name (str, optional) : A unique name for the created external repository (default 'pip').
90
+ **kwargs (dict) : Keyword arguments passed directly to the `pip_repository` repository rule.
82
91
"""
83
92
84
93
# Just in case our dependencies weren't already fetched
@@ -91,9 +100,11 @@ def pip_install(requirements, name = "pip", **kwargs):
91
100
)
92
101
93
102
def pip_parse (requirements_lock , name = "pip_parsed_deps" , ** kwargs ):
94
- """Imports a locked/compiled requirements file and generates a new `requirements.bzl` file.
103
+ """Accepts a locked/compiled requirements file and installs the dependencies listed within.
104
+
105
+ Those dependencies become available in a generated `requirements.bzl` file.
95
106
96
- This is used via the `WORKSPACE` pattern :
107
+ This macro runs a repository rule that invokes `pip`. In your WORKSPACE file :
97
108
98
109
```python
99
110
load("@rules_python//python:pip.bzl", "pip_parse")
@@ -108,7 +119,7 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
108
119
install_deps()
109
120
```
110
121
111
- You can then reference imported dependencies from your `BUILD` file with:
122
+ You can then reference installed dependencies from a `BUILD` file with:
112
123
113
124
```python
114
125
load("@pip_deps//:requirements.bzl", "requirement")
@@ -142,7 +153,7 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
142
153
)
143
154
```
144
155
145
- Note that for packages who's name and script are the same, only the name of the package
156
+ Note that for packages whose name and script are the same, only the name of the package
146
157
is needed when calling the `entry_point` macro.
147
158
148
159
```python
@@ -176,10 +187,23 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
176
187
)
177
188
178
189
def pip_repositories ():
190
+ """
191
+ Obsolete macro to pull in dependencies needed to use the pip_import rule.
192
+
193
+ Deprecated:
194
+ the pip_repositories rule is obsolete. It is not used by pip_install.
195
+ """
196
+
179
197
# buildifier: disable=print
180
198
print ("DEPRECATED: the pip_repositories rule has been replaced with pip_install, please see rules_python 0.1 release notes" )
181
199
182
200
def pip_import (** kwargs ):
201
+ """
202
+ Rule for installing packages listed in a requirements file.
203
+
204
+ Deprecated:
205
+ the pip_import rule has been replaced with pip_install.
206
+ """
183
207
fail ("=" * 79 + """\n
184
208
pip_import has been replaced with pip_install, please see the rules_python 0.1 release notes.
185
209
To continue using it, you can load from "@rules_python//python/legacy_pip_import:pip.bzl"
0 commit comments