Skip to content

Commit 0c811e0

Browse files
committed
Add pip_repository documentation
The macros are leaky and otherwise you have to read sources to find out about the kwargs Fixes #384
1 parent f480ebe commit 0c811e0

File tree

6 files changed

+170
-11
lines changed

6 files changed

+170
-11
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/*.md linguist-generated=true

docs/BUILD

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ licenses(["notice"]) # Apache 2.0
2424
_DOCS = {
2525
"packaging": "//docs:packaging-docs",
2626
"pip": "//docs:pip-docs",
27+
"pip_repository": "//docs:pip-repository",
2728
"python": "//docs:core-docs",
2829
}
2930

@@ -104,6 +105,18 @@ stardoc(
104105
],
105106
)
106107

108+
stardoc(
109+
name = "pip-repository",
110+
out = "pip_repository.md_",
111+
input = "//python/pip_install:pip_repository.bzl",
112+
target_compatible_with = _NOT_WINDOWS,
113+
deps = [
114+
":bazel_repo_tools",
115+
":pip_install_bzl",
116+
"//third_party/github.com/bazelbuild/bazel-skylib/lib:versions",
117+
],
118+
)
119+
107120
stardoc(
108121
name = "packaging-docs",
109122
out = "packaging.md_",

docs/pip.md

+7-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pip_repository.md

+140
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/pip.bzl

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def pip_install(requirements = None, name = "pip", **kwargs):
2525
2626
Those dependencies become available in a generated `requirements.bzl` file.
2727
28-
This macro runs a repository rule that invokes `pip`. In your WORKSPACE file:
28+
This macro wraps the [`pip_repository`](./pip_repository.md) rule that invokes `pip`.
29+
In your WORKSPACE file:
2930
3031
```python
3132
pip_install(
@@ -88,7 +89,7 @@ def pip_install(requirements = None, name = "pip", **kwargs):
8889
Args:
8990
requirements (Label): A 'requirements.txt' pip requirements file.
9091
name (str, optional): A unique name for the created external repository (default 'pip').
91-
**kwargs (dict): Keyword arguments passed directly to the `pip_repository` repository rule.
92+
**kwargs (dict): Additional arguments to the [`pip_repository`](./pip_repository.md) repository rule.
9293
"""
9394

9495
# Just in case our dependencies weren't already fetched
@@ -107,7 +108,8 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
107108
Those dependencies become available in a generated `requirements.bzl` file.
108109
You can instead check this `requirements.bzl` file into your repo, see the "vendoring" section below.
109110
110-
This macro runs a repository rule that invokes `pip`. In your WORKSPACE file:
111+
This macro wraps the [`pip_repository`](./pip_repository.md) rule that invokes `pip`, with `incremental` set.
112+
In your WORKSPACE file:
111113
112114
```python
113115
load("@rules_python//python:pip.bzl", "pip_parse")
@@ -191,10 +193,11 @@ def pip_parse(requirements_lock, name = "pip_parsed_deps", **kwargs):
191193
of 'requirements' no resolve will take place and pip_repository will create
192194
individual repositories for each of your dependencies so that wheels are
193195
fetched/built only for the targets specified by 'build/run/test'.
196+
Note that if your lockfile is platform-dependent, you can use the `requirements_[platform]`
197+
attributes.
194198
name (str, optional): The name of the generated repository. The generated repositories
195199
containing each requirement will be of the form <name>_<requirement-name>.
196-
**kwargs (dict): Additional keyword arguments for the underlying
197-
`pip_repository` rule.
200+
**kwargs (dict): Additional arguments to the [`pip_repository`](./pip_repository.md) repository rule.
198201
"""
199202

200203
# Just in case our dependencies weren't already fetched

python/pip_install/pip_repository.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _locked_requirements(rctx):
126126
requirements_txt = rctx.attr.requirements_darwin
127127
elif os.startswith("linux") and rctx.attr.requirements_linux != None:
128128
requirements_txt = rctx.attr.requirements_linux
129-
elif "win" in os:
129+
elif "win" in os and rctx.attr.requirements_windows != None:
130130
requirements_txt = rctx.attr.requirements_windows
131131
if not requirements_txt:
132132
fail("""\

0 commit comments

Comments
 (0)