Skip to content

Commit 63af927

Browse files
committed
Merge and fix changelog
Of branch 'feat-pypi-all-files-extracted' into feat.pypi.all.files
2 parents a68c31e + aac9bf7 commit 63af927

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ END_UNRELEASED_TEMPLATE
6565
* (pypi) To configure the environment for `requirements.txt` evaluation, use the newly added
6666
developer preview of the `pip.default` tag class. Only `rules_python` and root modules can use
6767
this feature. You can also configure `constraint_values` using `pip.default`.
68+
* (pypi) PyPI dependencies now expose an `:extracted_whl_files` filegroup target
69+
of all the files extracted from the wheel. This can be used in lieu of
70+
{obj}`whl_filegroup` to avoid copying/extracting wheel multiple times to
71+
get a subset of their files.
6872

6973
{#v0-0-0-removed}
7074
### Removed

docs/pypi/use.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Note, that the hub repo contains the following targets for each package:
4040
* `@pypi//numpy:data` - the {obj}`filegroup` that is for all of the extra files that are included
4141
as data in the `pkg` target.
4242
* `@pypi//numpy:dist_info` - the {obj}`filegroup` that is for all of the files in the `<pkg prefix with version>.distinfo` directory.
43+
* `@pypi//numpy:extracted_whl_files` - a {obj}`filegroup` of all the files
44+
extracted from the whl file.
4345
* `@pypi//numpy:whl` - the {obj}`filegroup` that is the `.whl` file itself which includes all of
4446
the transitive dependencies via the {attr}`filegroup.data` attribute.
4547

python/private/pypi/pkg_aliases.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ load(
7979
":labels.bzl",
8080
"DATA_LABEL",
8181
"DIST_INFO_LABEL",
82+
"EXTRACTED_WHEEL_FILES",
8283
"PY_LIBRARY_IMPL_LABEL",
8384
"PY_LIBRARY_PUBLIC_LABEL",
8485
"WHEEL_FILE_IMPL_LABEL",
@@ -151,6 +152,7 @@ def pkg_aliases(
151152
WHEEL_FILE_PUBLIC_LABEL: WHEEL_FILE_IMPL_LABEL if group_name else WHEEL_FILE_PUBLIC_LABEL,
152153
DATA_LABEL: DATA_LABEL,
153154
DIST_INFO_LABEL: DIST_INFO_LABEL,
155+
EXTRACTED_WHEEL_FILES: EXTRACTED_WHEEL_FILES,
154156
} | {
155157
x: x
156158
for x in extra_aliases or []

python/private/pypi/whl_library_targets.bzl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,6 @@ def whl_library_targets(
101101
data_exclude = [],
102102
srcs_exclude = [],
103103
tags = [],
104-
filegroups = {
105-
EXTRACTED_WHEEL_FILES: dict(
106-
include = ["**"],
107-
exclude = ["*.whl"],
108-
),
109-
DIST_INFO_LABEL: dict(
110-
include = ["site-packages/*.dist-info/**"],
111-
),
112-
DATA_LABEL: dict(
113-
include = ["data/**"],
114-
),
115-
},
116104
dependencies = [],
117105
dependencies_by_platform = {},
118106
dependencies_with_markers = {},
@@ -177,7 +165,22 @@ def whl_library_targets(
177165
tags = sorted(tags)
178166
data = [] + data
179167

180-
for filegroup_name, glob_kwargs in filegroups.items():
168+
_filegroups = {
169+
# TODO(#3011): Consider parsing the RECORD file to get a precise list of files
170+
# instead of relying on a glob with excludes.
171+
EXTRACTED_WHEEL_FILES: dict(
172+
include = ["**"],
173+
exclude = [name],
174+
),
175+
DIST_INFO_LABEL: dict(
176+
include = ["site-packages/*.dist-info/**"],
177+
),
178+
DATA_LABEL: dict(
179+
include = ["data/**"],
180+
),
181+
}
182+
183+
for filegroup_name, glob_kwargs in _filegroups.items():
181184
glob_kwargs = {"allow_empty": True} | glob_kwargs
182185
native.filegroup(
183186
name = filegroup_name,

python/private/whl_filegroup/whl_filegroup.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ cc_library(
4242
includes = ["numpy_includes/numpy/core/include"],
4343
deps = ["@rules_python//python/cc:current_py_cc_headers"],
4444
)
45+
4546
```
47+
48+
:::{seealso}
49+
50+
The `:extracted_whl_files` target, which is a filegroup of all the files
51+
from the already extracted whl file.
52+
:::
4653
""",
4754
attrs = {
4855
"pattern": attr.string(default = "", doc = "Only file paths matching this regex pattern will be extracted."),

0 commit comments

Comments
 (0)