Skip to content

Commit b98ef19

Browse files
authored
Merge branch 'main' into patch-4
2 parents a79f88d + 8c33aa6 commit b98ef19

File tree

15 files changed

+593
-683
lines changed

15 files changed

+593
-683
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: "🏗️ Patch release or backport"
3+
about: Request a patch release or backport of a fix to a release.
4+
title: 'Patch release: MAJOR.MINOR.PATCH'
5+
labels: 'type: process'
6+
---
7+
8+
<!--
9+
Thank you for requesting a backport. Before submitting, please read:
10+
11+
* Backport policy: https://rules-python.readthedocs.io/en/latest/support.html#backports-and-patch-releases
12+
-->
13+
14+
**What version of `rules_python` do you want to patch?**
15+
16+
17+
**What pull requests do you want to backport?**
18+
19+
Please provide a list of pull request numbers.
20+
21+
- #
22+
- #

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ END_UNRELEASED_TEMPLATE
6969
* (toolchain) Python 3.13 now references 3.13.6
7070
* (gazelle) Switched back to smacker/go-tree-sitter, fixing
7171
[#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.
7276
* (ci) We are now testing on Ubuntu 22.04 for RBE and non-RBE configurations.
7377
* (core) `#!/usr/bin/env bash` is now used as a shebang in the stage1 bootstrap template.
7478
* (gazelle:docs) The Gazelle docs have been migrated from {gh-path}`gazelle/README.md` to
@@ -90,6 +94,10 @@ END_UNRELEASED_TEMPLATE
9094
([#2503](https://github.com/bazel-contrib/rules_python/issues/2503)).
9195
* (pypi) The pipstar `defaults` configuration now supports any custom platform
9296
name.
97+
* (pypi) The selection of the whls has been changed and should no longer result
98+
in ambiguous select matches ({gh-issue}`2759`) and should be much more efficient
99+
when running `bazel query` due to fewer repositories being included
100+
({gh-issue}`2849`).
93101
* Multi-line python imports (e.g. with escaped newlines) are now correctly processed by Gazelle.
94102
* (toolchains) `local_runtime_repo` works with multiarch Debian with Python 3.8
95103
([#3099](https://github.com/bazel-contrib/rules_python/issues/3099)).

MODULE.bazel

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +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+
whl_abi_tags = [
78+
"abi3",
79+
"cp{major}{minor}",
80+
],
81+
whl_platform_tags = [
82+
"linux_{}".format(cpu),
83+
"manylinux_*_{}".format(cpu),
84+
],
7785
)
7886
for cpu in [
7987
"x86_64",
8088
"aarch64",
81-
# TODO @aignas 2025-05-19: only leave tier 0-1 cpus when stabilizing the
82-
# `pip.default` extension. i.e. drop the below values - users will have to
83-
# define themselves if they need them.
84-
"arm",
85-
"ppc",
86-
"s390x",
8789
]
8890
]
8991

@@ -99,26 +101,53 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
99101
env = {"platform_version": "14.0"},
100102
os_name = "osx",
101103
platform = "osx_{}".format(cpu),
104+
whl_abi_tags = [
105+
"abi3",
106+
"cp{major}{minor}",
107+
],
108+
whl_platform_tags = [
109+
"macosx_*_{}".format(suffix)
110+
for suffix in platform_tag_cpus
111+
],
102112
)
103-
for cpu in [
104-
"aarch64",
105-
"x86_64",
106-
]
113+
for cpu, platform_tag_cpus in {
114+
"aarch64": [
115+
"universal2",
116+
"arm64",
117+
],
118+
"x86_64": [
119+
"universal2",
120+
"x86_64",
121+
],
122+
}.items()
123+
]
124+
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()
107144
]
108145

109-
pip.default(
110-
arch_name = "x86_64",
111-
config_settings = [
112-
"@platforms//cpu:x86_64",
113-
"@platforms//os:windows",
114-
],
115-
env = {"platform_version": "0"},
116-
os_name = "windows",
117-
platform = "windows_x86_64",
118-
)
119146
pip.parse(
120147
# NOTE @aignas 2024-10-26: We have an integration test that depends on us
121148
# being able to build sdists for this hub, so explicitly set this to False.
149+
#
150+
# how do we test sdists? Maybe just worth adding a single sdist somewhere?
122151
download_only = False,
123152
experimental_index_url = "https://pypi.org/simple",
124153
hub_name = "rules_python_publish_deps",

docs/devguide.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,35 @@ to have everything self-documented, we have a special target,
116116
`//private:requirements.update`, which uses `rules_multirun` to run all
117117
of the requirement-updating scripts in sequence in one go. This can be done once per release as
118118
we prepare for releases.
119+
120+
## Creating Backport PRs
121+
122+
The steps to create a backport PR are:
123+
124+
1. Create an issue for the patch release; use the [patch relase
125+
template][patch-release-issue].
126+
2. Create a fork of `rules_python`.
127+
3. Checkout the `release/X.Y` branch.
128+
4. Use `git cherry-pick -x` to cherry pick the desired fixes.
129+
5. Update the release's `CHANGELOG.md` file:
130+
* Add a Major.Minor.Patch section if one doesn't exist
131+
* Copy the changelog text from `main` to the release's changelog.
132+
6. Send a PR with the backport's changes.
133+
* The title should be `backport: PR#N to Major.Minor`
134+
* The body must preserve the original PR's number, commit hash, description,
135+
and authorship.
136+
Use the following format (`git cherry-pick` will use this format):
137+
```
138+
<original PR title>
139+
140+
<original PR body>
141+
(cherry picked from commit <commit hash>)
142+
-----
143+
Co-authored-by: <original PR author; separate lines for each>
144+
```
145+
* If the PR contains multiple backport commits, separate each's description
146+
with `-----`.
147+
7. Send a PR to update the `main` branch's `CHANGELOG.md` to reflect the
148+
changes done in the patched release.
149+
150+
[patch-release-issue]: https://github.com/bazelbuild/rules_python/issues/new?template=patch_release.md

docs/support.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ the willingness of volunteers.
1414
If you want or need particular functionality backported, then the best way
1515
is to open a PR to demonstrate the feasibility of the backport.
1616

17+
### Backports and Patch Releases
18+
19+
Backports and patch releases are provided on a best-effort basis. Only fixes are
20+
backported. Features are not backported.
21+
22+
Backports can be done to older releases, but only if newer releases also have
23+
the fix backported. For example, if the current release is 1.5, in order to
24+
patch 1.4, version 1.5 must be patched first.
25+
26+
Backports can be requested by [creating an issue with the patch release
27+
template][patch-release-issue] or by sending a pull request performing the backport.
28+
See the dev guide for [how to create a backport PR][backport-pr].
29+
30+
[patch-release-issue]: https://github.com/bazelbuild/rules_python/issues/new?template=patch_release_request.md
31+
[backport-pr]: devguide.html#creating-backport-prs
32+
1733
## Supported Bazel Versions
1834

1935
The supported Bazel versions are:

examples/bzlmod/MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ pip.whl_mods(
158158
)
159159
use_repo(pip, "whl_mods_hub")
160160

161+
# Because below we are using `windows_aarch64` platform, we have to define various
162+
# properties for it.
163+
pip.default(
164+
arch_name = "aarch64",
165+
config_settings = [
166+
"@platforms//os:windows",
167+
"@platforms//cpu:aarch64",
168+
],
169+
env = {
170+
"platform_version": "0",
171+
},
172+
os_name = "windows",
173+
platform = "windows_aarch64",
174+
whl_abi_tags = [], # default to all ABIs
175+
whl_platform_tags = ["win_amd64"],
176+
)
177+
161178
# To fetch pip dependencies, use pip.parse. We can pass in various options,
162179
# but typically we pass requirements and the Python version. The Python
163180
# version must have been configured by a corresponding `python.toolchain()`

python/private/pypi/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ bzl_library(
116116
":parse_whl_name_bzl",
117117
":pep508_env_bzl",
118118
":pip_repository_attrs_bzl",
119+
":python_tag_bzl",
119120
":simpleapi_download_bzl",
120121
":whl_config_setting_bzl",
121122
":whl_library_bzl",
122123
":whl_repo_name_bzl",
123-
":whl_target_platforms_bzl",
124124
"//python/private:full_version_bzl",
125125
"//python/private:normalize_name_bzl",
126126
"//python/private:version_bzl",
@@ -209,7 +209,7 @@ bzl_library(
209209
":parse_requirements_txt_bzl",
210210
":pypi_repo_utils_bzl",
211211
":requirements_files_by_platform_bzl",
212-
":whl_target_platforms_bzl",
212+
":select_whl_bzl",
213213
"//python/private:normalize_name_bzl",
214214
"//python/private:repo_utils_bzl",
215215
],
@@ -438,5 +438,4 @@ bzl_library(
438438
bzl_library(
439439
name = "whl_target_platforms_bzl",
440440
srcs = ["whl_target_platforms.bzl"],
441-
deps = [":parse_whl_name_bzl"],
442441
)

python/private/pypi/evaluate_markers.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ def evaluate_markers(*, requirements, platforms):
4343
for req_string, platform_strings in requirements.items():
4444
req = requirement(req_string)
4545
for platform_str in platform_strings:
46-
env = platforms.get(platform_str)
47-
if not env:
46+
plat = platforms.get(platform_str)
47+
if not plat:
4848
fail("Please define platform: '{}'".format(platform_str))
4949

50-
if evaluate(req.marker, env = env):
50+
if evaluate(req.marker, env = plat.env):
5151
ret.setdefault(req_string, []).append(platform_str)
5252

5353
return ret

0 commit comments

Comments
 (0)