@@ -20,17 +20,19 @@ load("//python/pip_install:requirements.bzl", _compile_pip_requirements = "compi
2020compile_pip_requirements = _compile_pip_requirements
2121
2222def 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 .
2424
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:
2628
2729 ```python
2830 pip_install(
2931 requirements = ":requirements.txt",
3032 )
3133 ```
3234
33- You can then reference imported dependencies from your `BUILD` file with:
35+ You can then reference installed dependencies from a `BUILD` file with:
3436
3537 ```python
3638 load("@pip//:requirements.bzl", "requirement")
@@ -45,9 +47,16 @@ def pip_install(requirements, name = "pip", **kwargs):
4547 )
4648 ```
4749
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.
5160
5261 [whl_ep]: https://packaging.python.org/specifications/entry-points/
5362
@@ -63,7 +72,7 @@ def pip_install(requirements, name = "pip", **kwargs):
6372 )
6473 ```
6574
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
6776 is needed when calling the `entry_point` macro.
6877
6978 ```python
@@ -76,9 +85,9 @@ def pip_install(requirements, name = "pip", **kwargs):
7685 ```
7786
7887 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.
8291 """
8392
8493 # Just in case our dependencies weren't already fetched
@@ -91,9 +100,11 @@ def pip_install(requirements, name = "pip", **kwargs):
91100 )
92101
93102def 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.
95106
96- This is used via the `WORKSPACE` pattern :
107+ This macro runs a repository rule that invokes `pip`. In your WORKSPACE file :
97108
98109 ```python
99110 load("@rules_python//python:pip.bzl", "pip_parse")
@@ -108,7 +119,7 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
108119 install_deps()
109120 ```
110121
111- You can then reference imported dependencies from your `BUILD` file with:
122+ You can then reference installed dependencies from a `BUILD` file with:
112123
113124 ```python
114125 load("@pip_deps//:requirements.bzl", "requirement")
@@ -142,7 +153,7 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
142153 )
143154 ```
144155
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
146157 is needed when calling the `entry_point` macro.
147158
148159 ```python
@@ -176,10 +187,23 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
176187 )
177188
178189def 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+
179197 # buildifier: disable=print
180198 print ("DEPRECATED: the pip_repositories rule has been replaced with pip_install, please see rules_python 0.1 release notes" )
181199
182200def 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+ """
183207 fail ("=" * 79 + """\n
184208 pip_import has been replaced with pip_install, please see the rules_python 0.1 release notes.
185209 To continue using it, you can load from "@rules_python//python/legacy_pip_import:pip.bzl"
0 commit comments