@@ -188,7 +188,7 @@ load("@my_deps//:requirements.bzl", "pip_install")
188188pip_install()
189189```
190190
191- An example can be found in [ `examples/legacy_pip_import] ( examples/legacy_pip_import ) .
191+ An example can be found in [ ` examples/legacy_pip_import ` ] ( examples/legacy_pip_import ) .
192192
193193### Consuming ` pip ` dependencies
194194
@@ -197,9 +197,7 @@ wheel's contents. Rather than depend on this target's label directly -- which
197197would require hardcoding the wheel repo's mangled name into your BUILD files --
198198you should instead use the ` requirement() ` function defined in the central
199199repo's ` //:requirements.bzl ` file. This function maps a pip package name to a
200- label. ([ "Extras"] (
201- https://packaging.python.org/tutorials/installing-packages/#installing-setuptools-extras )
202- can be referenced using the ` pkg[extra] ` syntax.)
200+ label.
203201
204202``` python
205203load(" @my_deps//:requirements.bzl" , " requirement" )
@@ -210,17 +208,35 @@ py_library(
210208 deps = [
211209 " :myotherlib" ,
212210 requirement(" some_pip_dep" ),
213- requirement(" another_pip_dep[some_extra] " ),
211+ requirement(" another_pip_dep" ),
214212 ]
215213)
216214```
217215
216+
218217For reference, the wheel repos are canonically named following the pattern:
219218` @{central_repo_name}_pypi__{distribution}_{version} ` . Characters in the
220219distribution and version that are illegal in Bazel label names (e.g. ` - ` , ` . ` )
221220are replaced with ` _ ` . While this naming pattern doesn't change often, it is
222- not guaranted to remain stable, so use of the ` requirement() ` function is
223- recommended.
221+ not guaranted to remain stable, so use of the ` requirement() ` function is recommended.
222+
223+ #### 'Extras' requirement consumption
224+
225+ When using the legacy ` pip_import ` , you must specify the extra in the argument to the ` requirement ` macro. For example:
226+
227+ ``` python
228+ py_library(
229+ name = " mylib" ,
230+ srcs = [" mylib.py" ],
231+ deps = [
232+ requirement(" useful_dep[some_extra]" ),
233+ ]
234+ )
235+ ```
236+
237+ If using ` pip_install ` or ` pip_parse ` , any extras specified in the requirements file will be automatically
238+ linked as a dependency of the package so that you don't need to specify the extra. In the example above,
239+ you'd just put ` requirement("useful_dep") ` .
224240
225241### Consuming Wheel Dists Directly
226242
0 commit comments