Skip to content

Commit 029a4dc

Browse files
docs: improve whl_library documentation (#3266)
The documentation for the `whl_patches` argument of `whl_library` contained an error. I fixed it and also elaborated the text in places that tripped me up. --------- Co-authored-by: Richard Levasseur <[email protected]>
1 parent 35adf5c commit 029a4dc

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

python/private/pypi/whl_library.bzl

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ whl_library_attrs = dict({
577577
The dep template to use for referencing the dependencies. It should have `{name}`
578578
and `{target}` tokens that will be replaced with the normalized distribution name
579579
and the target that we need respectively.
580+
581+
For example if your whl depends on `numpy` and your Python package repo is named
582+
`pip` so that you would normally do `@pip//numpy`, then this should be: `@pip//{name}`.
580583
""",
581584
),
582585
"filename": attr.string(
@@ -615,11 +618,29 @@ attr makes `extra_pip_args` and `download_only` ignored.""",
615618
doc = "The whl file that should be used instead of downloading or building the whl.",
616619
),
617620
"whl_patches": attr.label_keyed_string_dict(
618-
doc = """a label-keyed-string dict that has
619-
json.encode(struct([whl_file], patch_strip]) as values. This
620-
is to maintain flexibility and correct bzlmod extension interface
621-
until we have a better way to define whl_library and move whl
622-
patching to a separate place. INTERNAL USE ONLY.""",
621+
doc = """
622+
A label-keyed-string dict with patch files as keys and json-strings as values.
623+
624+
The keys are labels to the patch file to apply.
625+
626+
The values describe what to apply the patch to and how to apply it.
627+
It is encoded as `json.encode(struct([whls], patch_strip])`,
628+
where `whls` is a `list[str`] of wheel filenames, and `patch_strip`
629+
is a number.
630+
631+
So it will look something like this:
632+
```
633+
"//path/to/package:my.patch": json.encode(struct(
634+
whls = ["something-2.7.1-py3-none-any.whl"],
635+
patch_strip = 1,
636+
)),
637+
```
638+
The patch is applied within the scope of the .whl file.
639+
I.e. you should create the patch from the same place you unziped the wheel.
640+
641+
642+
This is to maintain flexibility and correct bzlmod extension interface until we have a better
643+
way to define whl_library and move whl patching to a separate place. INTERNAL USE ONLY.""",
623644
),
624645
"_python_path_entries": attr.label_list(
625646
# Get the root directory of these rules and keep them as a default attribute

0 commit comments

Comments
 (0)