Skip to content

Commit f1d8f64

Browse files
committed
Merge branch 'exp/pypi-simplify' into exp/pypi-simplify-freethreaded
2 parents 5e66b5b + 82e1532 commit f1d8f64

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

+1614
-1014
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: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,18 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
7878
marker = "python_version ~= \"3.13\"" if freethreaded else "",
7979
os_name = "linux",
8080
platform = "linux_{}{}".format(cpu, freethreaded),
81-
platform_tags = [
81+
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
82+
"abi3",
83+
"cp{major}{minor}",
84+
],
85+
whl_platform_tags = [
8286
"linux_*_{}".format(cpu),
8387
"manylinux_*_{}".format(cpu),
8488
],
85-
want_abis = [
86-
"cp{0}{1}t",
87-
"none",
88-
] if freethreaded else [],
8989
)
9090
for cpu in [
9191
"x86_64",
9292
"aarch64",
93-
# TODO @aignas 2025-05-19: only leave tier 0-1 cpus when stabilizing the
94-
# `pip.default` extension. i.e. drop the below values - users will have to
95-
# define themselves if they need them.
96-
"arm",
97-
"ppc",
98-
"s390x",
9993
]
10094
for freethreaded in [
10195
"",
@@ -119,14 +113,14 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
119113
marker = "python_version ~= \"3.13\"" if freethreaded else "",
120114
os_name = "osx",
121115
platform = "osx_{}{}".format(cpu, freethreaded),
122-
platform_tags = [
116+
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
117+
"abi3",
118+
"cp{major}{minor}",
119+
],
120+
whl_platform_tags = [
123121
"macosx_*_{}".format(suffix)
124122
for suffix in platform_tag_cpus
125123
],
126-
want_abis = [
127-
"cp{0}{1}t",
128-
"none",
129-
] if freethreaded else [],
130124
)
131125
for cpu, platform_tag_cpus in {
132126
"aarch64": [
@@ -146,9 +140,9 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
146140

147141
[
148142
pip.default(
149-
arch_name = "x86_64",
143+
arch_name = cpu,
150144
config_settings = [
151-
"@platforms//cpu:x86_64",
145+
"@platforms//cpu:{}".format(cpu),
152146
"@platforms//os:windows",
153147
"//python/config_settings:_is_py_freethreaded_{}".format(
154148
"yes" if freethreaded else "no",
@@ -157,13 +151,16 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
157151
env = {"platform_version": "0"},
158152
marker = "python_version ~= \"3.13\"" if freethreaded else "",
159153
os_name = "windows",
160-
platform = "windows_x86_64{}".format(freethreaded),
161-
platform_tags = ["win_amd64"],
162-
want_abis = [
163-
"cp{0}{1}t",
164-
"none",
165-
] if freethreaded else [],
154+
platform = "windows_{}{}".format(cpu, freethreaded),
155+
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
156+
"abi3",
157+
"cp{major}{minor}",
158+
],
159+
whl_platform_tags = whl_platform_tags,
166160
)
161+
for cpu, whl_platform_tags in {
162+
"x86_64": ["win_amd64"],
163+
}.items()
167164
for freethreaded in [
168165
"",
169166
"_freethreaded",
@@ -214,6 +211,8 @@ internal_dev_deps = use_extension(
214211
use_repo(
215212
internal_dev_deps,
216213
"buildkite_config",
214+
"implicit_namespace_ns_sub1",
215+
"implicit_namespace_ns_sub2",
217216
"rules_python_runtime_env_tc_info",
218217
"somepkg_with_build_files",
219218
"whl_with_build_files",
@@ -267,19 +266,22 @@ dev_pip = use_extension(
267266
dev_dependency = True,
268267
)
269268
dev_pip.parse(
269+
download_only = True,
270270
experimental_index_url = "https://pypi.org/simple",
271271
hub_name = "dev_pip",
272272
parallel_download = False,
273273
python_version = "3.11",
274274
requirements_lock = "//docs:requirements.txt",
275275
)
276276
dev_pip.parse(
277+
download_only = True,
277278
experimental_index_url = "https://pypi.org/simple",
278279
hub_name = "dev_pip",
279280
python_version = "3.13",
280281
requirements_lock = "//docs:requirements.txt",
281282
)
282283
dev_pip.parse(
284+
download_only = True,
283285
experimental_index_url = "https://pypi.org/simple",
284286
hub_name = "pypiserver",
285287
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)