Skip to content

Commit b5290c4

Browse files
committed
Merge branch 'exp/pypi-simplify' into exp/pypi-simplify-cleanup
2 parents 3141590 + 82e1532 commit b5290c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1619
-1008
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ END_UNRELEASED_TEMPLATE
6767
* 3.12.11
6868
* 3.14.0b3
6969
* (toolchain) Python 3.13 now references 3.13.5
70+
* (gazelle) Switched back to smacker/go-tree-sitter, fixing
71+
[#2630](https://github.com/bazel-contrib/rules_python/issues/2630)
72+
* (pypi) From now on the list of default platforms only includes `linux_x86_64`, `linux_aarch64`,
73+
`osx_x86_64`, `osx_aarch64` and `windows_x86_64`. If you are on other platforms, you need to
74+
use the `pip.default` to configure it yourself. If you are interested in graduating the
75+
platform, consider helping set us up CI for them and update the documentation.
7076

7177
{#v0-0-0-fixed}
7278
### Fixed
@@ -84,12 +90,20 @@ END_UNRELEASED_TEMPLATE
8490
({gh-issue}`3043`).
8591
* (pypi) The pipstar `defaults` configuration now supports any custom platform
8692
name.
93+
* (pypi) The selection of the whls has been changed and should no longer result
94+
in ambiguous select matches ({gh-issue}`2759`) and should be much more efficient
95+
when running `bazel query` due to fewer repositories being included
96+
({gh-issue}`2849`).
8797

8898
{#v0-0-0-added}
8999
### Added
90100
* (pypi) To configure the environment for `requirements.txt` evaluation, use the newly added
91101
developer preview of the `pip.default` tag class. Only `rules_python` and root modules can use
92102
this feature. You can also configure custom `config_settings` using `pip.default`.
103+
* (pypi) PyPI dependencies now expose an `:extracted_whl_files` filegroup target
104+
of all the files extracted from the wheel. This can be used in lieu of
105+
{obj}`whl_filegroup` to avoid copying/extracting wheel multiple times to
106+
get a subset of their files.
93107
* (gazelle) New directive `gazelle:python_generate_pyi_deps`; when `true`,
94108
dependencies added to satisfy type-only imports (`if TYPE_CHECKING`) and type
95109
stub packages are added to `pyi_deps` instead of `deps`.

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,13 @@ merged:
234234
## Binary artifacts
235235

236236
Checking in binary artifacts is not allowed. This is because they are extremely
237-
problematic to verify and ensure they're safe
237+
problematic to verify and ensure they're safe. This is true even in
238+
test contexts.
238239

239240
Examples include, but aren't limited to: prebuilt binaries, shared libraries,
240241
zip files, or wheels.
241242

243+
See the dev guide for utilities to help with testing.
242244

243245
(breaking-changes)=
244246
## Breaking Changes

MODULE.bazel

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,18 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
7474
env = {"platform_version": "0"},
7575
os_name = "linux",
7676
platform = "linux_{}".format(cpu),
77-
platform_tags = [
77+
whl_abi_tags = [
78+
"abi3",
79+
"cp{major}{minor}",
80+
],
81+
whl_platform_tags = [
7882
"linux_*_{}".format(cpu),
7983
"manylinux_*_{}".format(cpu),
8084
],
8185
)
8286
for cpu in [
8387
"x86_64",
8488
"aarch64",
85-
# TODO @aignas 2025-05-19: only leave tier 0-1 cpus when stabilizing the
86-
# `pip.default` extension. i.e. drop the below values - users will have to
87-
# define themselves if they need them.
88-
"arm",
89-
"ppc",
90-
"s390x",
9189
]
9290
]
9391

@@ -103,7 +101,11 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
103101
env = {"platform_version": "14.0"},
104102
os_name = "osx",
105103
platform = "osx_{}".format(cpu),
106-
platform_tags = [
104+
whl_abi_tags = [
105+
"abi3",
106+
"cp{major}{minor}",
107+
],
108+
whl_platform_tags = [
107109
"macosx_*_{}".format(suffix)
108110
for suffix in platform_tag_cpus
109111
],
@@ -120,17 +122,27 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
120122
}.items()
121123
]
122124

123-
pip.default(
124-
arch_name = "x86_64",
125-
config_settings = [
126-
"@platforms//cpu:x86_64",
127-
"@platforms//os:windows",
128-
],
129-
env = {"platform_version": "0"},
130-
os_name = "windows",
131-
platform = "windows_x86_64",
132-
platform_tags = ["win_amd64"],
133-
)
125+
[
126+
pip.default(
127+
arch_name = cpu,
128+
config_settings = [
129+
"@platforms//cpu:{}".format(cpu),
130+
"@platforms//os:windows",
131+
],
132+
env = {"platform_version": "0"},
133+
os_name = "windows",
134+
platform = "windows_{}".format(cpu),
135+
whl_abi_tags = [
136+
"abi3",
137+
"cp{major}{minor}",
138+
],
139+
whl_platform_tags = whl_platform_tags,
140+
)
141+
for cpu, whl_platform_tags in {
142+
"x86_64": ["win_amd64"],
143+
}.items()
144+
]
145+
134146
pip.parse(
135147
# NOTE @aignas 2024-10-26: We have an integration test that depends on us
136148
# being able to build sdists for this hub, so explicitly set this to False.
@@ -175,6 +187,8 @@ internal_dev_deps = use_extension(
175187
use_repo(
176188
internal_dev_deps,
177189
"buildkite_config",
190+
"implicit_namespace_ns_sub1",
191+
"implicit_namespace_ns_sub2",
178192
"rules_python_runtime_env_tc_info",
179193
"somepkg_with_build_files",
180194
"whl_with_build_files",
@@ -228,19 +242,22 @@ dev_pip = use_extension(
228242
dev_dependency = True,
229243
)
230244
dev_pip.parse(
245+
download_only = True,
231246
experimental_index_url = "https://pypi.org/simple",
232247
hub_name = "dev_pip",
233248
parallel_download = False,
234249
python_version = "3.11",
235250
requirements_lock = "//docs:requirements.txt",
236251
)
237252
dev_pip.parse(
253+
download_only = True,
238254
experimental_index_url = "https://pypi.org/simple",
239255
hub_name = "dev_pip",
240256
python_version = "3.13",
241257
requirements_lock = "//docs:requirements.txt",
242258
)
243259
dev_pip.parse(
260+
download_only = True,
244261
experimental_index_url = "https://pypi.org/simple",
245262
hub_name = "pypiserver",
246263
python_version = "3.11",

docs/devguide.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ to be perfectly factored and not every common thing a test does needs to be
3737
factored into a more generally reusable piece. Copying and pasting is fine. It's
3838
more important for tests to balance understandability and maintainability.
3939

40+
### Test utilities
41+
42+
General code to support testing is in {gh-path}`tests/support`. It has a variety
43+
of functions, constants, rules etc, to make testing easier. Below are some
44+
common utilities that are frequently used.
45+
4046
### sh_py_run_test
4147

4248
The {gh-path}`sh_py_run_test <tests/support/sh_py_run_test.bzl` rule is a helper to
@@ -68,6 +74,12 @@ the rule. To have it support setting a new flag:
6874
list, then modify the transition's logic to check the attribute and set
6975
the flag value if the attribute is set.
7076

77+
### whl_from_dir_repo
78+
79+
The `whl_from_dir_repo` repository rule in {gh-path}`tests/support/whl_from_dir`
80+
takes a directory tree and turns it into a `.whl` file. This can be used to
81+
create arbitrary whl files to verify functionality.
82+
7183
### Integration tests
7284

7385
An integration test is one that runs a separate Bazel instance inside the test.

docs/pypi/use.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ Note that the hub repo contains the following targets for each package:
4040
* `@pypi//numpy:data` - the {obj}`filegroup` for all of the extra files that are included
4141
as data in the `pkg` target.
4242
* `@pypi//numpy:dist_info` - the {obj}`filegroup` 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
4446
transitive dependencies via the {attr}`filegroup.data` attribute.
4547

48+
:::{versionadded} VERSION_NEXT_FEATURE
49+
50+
The `:extracted_whl_files` target was added
51+
:::
52+
4653
## Entry points
4754

4855
If you would like to access [entry points][whl_ep], see the `py_console_script_binary` rule documentation,

0 commit comments

Comments
 (0)