Skip to content

Commit 22fb07c

Browse files
authored
Merge branch 'main' into update-pypi-deps-docs-20260501
2 parents ba1ae58 + ee7c54b commit 22fb07c

157 files changed

Lines changed: 2101 additions & 2502 deletions

File tree

Some content is hidden

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

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ sphinxdocs
3333
tests/integration/compile_pip_requirements/bazel-compile_pip_requirements
3434
tests/integration/local_toolchains/bazel-local_toolchains
3535
tests/integration/py_cc_toolchain_registered/bazel-py_cc_toolchain_registered
36+
tests/integration/toolchain_target_settings/bazel-module_under_test

.bazelrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ common --incompatible_disallow_struct_provider_syntax
2525
# Makes Bazel 7 act more like Bazel 8
2626
common --incompatible_use_plus_in_repo_names
2727

28+
# Implicitly adds --config=linux|macos|windows, depending on the host platform
29+
common --enable_platform_specific_config
30+
2831
# Needed to make Windows with a py_binary in data deps work. The Bazel launcher
2932
# is used, which falls back to finding python.exe on PATH to bootstrap.
3033
# See https://github.com/bazel-contrib/rules_python/issues/3655
@@ -55,6 +58,20 @@ common --incompatible_no_implicit_file_export
5558

5659
build --lockfile_mode=update
5760

61+
# Silence spammy C++ compile warnings
62+
build:linux --copt=-Wno-deprecated-declarations
63+
build:linux --copt=-Wno-stringop-overread
64+
build:linux --copt=-Wno-sign-compare
65+
build:linux --host_copt=-Wno-deprecated-declarations
66+
build:linux --host_copt=-Wno-stringop-overread
67+
build:linux --host_copt=-Wno-sign-compare
68+
build:macos --copt=-Wno-deprecated-declarations
69+
build:macos --copt=-Wno-stringop-overread
70+
build:macos --copt=-Wno-sign-compare
71+
build:macos --host_copt=-Wno-deprecated-declarations
72+
build:macos --host_copt=-Wno-stringop-overread
73+
build:macos --host_copt=-Wno-sign-compare
74+
5875
import %workspace%/specialized_configs.bazelrc
5976

6077
try-import user.bazelrc

.bazelrc.deleted_packages

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ common --deleted_packages=tests/integration/custom_commands
3535
common --deleted_packages=tests/integration/local_toolchains
3636
common --deleted_packages=tests/integration/pip_parse
3737
common --deleted_packages=tests/integration/pip_parse/empty
38+
common --deleted_packages=tests/integration/pip_parse_isolated
3839
common --deleted_packages=tests/integration/py_cc_toolchain_registered
40+
common --deleted_packages=tests/integration/toolchain_target_settings
3941
common --deleted_packages=tests/modules/another_module
4042
common --deleted_packages=tests/modules/other
4143
common --deleted_packages=tests/modules/other/nspkg_delta

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
/examples/build_file_generation/ @dougthor42 @aignas
88

99
# PyPI integration related code
10-
/python/private/pypi/ @rickeylev @aignas @groodt
11-
/tests/pypi/ @rickeylev @aignas @groodt
10+
/python/private/pypi/ @rickeylev @aignas
11+
/tests/pypi/ @rickeylev @aignas

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Create release archive and notes
4747
run: .github/workflows/create_archive_and_notes.sh ${{ inputs.tag_name || github.ref_name }}
4848
- name: Release
49-
uses: softprops/action-gh-release@v2
49+
uses: softprops/action-gh-release@v3
5050
with:
5151
# Use GH feature to populate the changelog automatically
5252
generate_release_notes: true

AGENTS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project.
55

66
Act as an expert in Bazel, rules_python, Starlark, and Python.
77

8-
DO NOT `git commit` or `git push`.
8+
DO NOT `git commit` or `git push` unless given explicit permission.
99

1010
## RULES TO ALWAYS FOLLOW AND NEVER IGNORE
1111

@@ -30,6 +30,11 @@ into the sentence, not verbatim.
3030
When adding `{versionadded}` or `{versionchanged}` sections, add them add the
3131
end of the documentation text.
3232

33+
### PR descriptions
34+
35+
Follow the advice in `CONTRIBUTING.md` for PR descriptions. PR descriptions
36+
become the commit message upon merge.
37+
3338
### Starlark style
3439

3540
For doc strings, using triple quoted strings when the doc string is more than

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,38 @@ END_UNRELEASED_TEMPLATE
6060
### Changed
6161
* (gazelle) WORKSPACE's bazel-gazelle dependency bumped from 0.36.0 to 0.47.0.
6262
The go version was also bumped from 1.21.13 to 1.22.9.
63+
* (pypi) The data files of a wheel (bin, includes, etc) are now always included
64+
as a library's data dependencies.
6365

6466
{#v0-0-0-fixed}
6567
### Fixed
6668
* (gazelle) Fixed handling of auto-included `__init__.py` files when generating `py_binary`
6769
targets ([#3729](https://github.com/bazel-contrib/rules_python/issues/3729)).
70+
* (entry_point) From now on `mypy` type checking will be skipped on the generated
71+
files ([#3126](https://github.com/bazel-contrib/rules_python/issues/3126)).
72+
* (pypi) Support `--experimental_isolated_extension_usages`
73+
([#3668](https://github.com/bazel-contrib/rules_python/issues/3668)).
74+
* (uv) use the astral.sh mirror as the preferred url for binary downloads,
75+
with github.com as a fallback; for uv >= 0.11.0, read the checksums directly
76+
from the dist-manifest contents.
6877

6978
{#v0-0-0-added}
7079
### Added
80+
* (toolchain) Added {obj}`python.override.toolchain_target_settings` to allow
81+
adding `config_setting` labels to all registered toolchains.
7182
* (windows) Full venv support for Windows is available. Set
7283
{obj}`--venvs_site_packages=yes` to enable.
84+
* (test/binaries) When {obj}`--venv_site_packages=yes` is enabled,
85+
wheel `data`, `bin`, and `include` files are populated into the venv.
7386
* (runfiles) Added a pathlib-compatible API: {obj}`Runfiles.root()`
7487
Fixes [#3296](https://github.com/bazel-contrib/rules_python/issues/3296).
88+
* (gazelle) Support alias_kind directive.
89+
Fixes [#3183](https://github.com/bazel-contrib/rules_python/issues/3183).
7590
* (toolchains) `3.13.12`, `3.14.3` Python toolchain from [20260325] release.
7691
* (toolchains) `3.10.20`, `3.11.15`, `3.12.13`, `3.13.13` `3.14.4`, `3.15.0a8`
7792
* Python toolchain from [20260414] release.
93+
* (pypi) `package_metadata` support, fixes
94+
[#2054](https://github.com/bazel-contrib/rules_python/issues/2054).
7895

7996
[20260325]: https://github.com/astral-sh/python-build-standalone/releases/tag/20260325
8097
[20260414]: https://github.com/astral-sh/python-build-standalone/releases/tag/20260414

CONTRIBUTING.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ information on using pull requests.
103103

104104
[GitHub Help]: https://help.github.com/articles/about-pull-requests/
105105

106-
### Commit messages
106+
### Commit messages and PR descriptions
107107

108108
Commit messages (upon merging) and PR messages should follow the [Conventional
109109
Commits](https://www.conventionalcommits.org/) style:
@@ -139,9 +139,36 @@ Common `type`s:
139139
* `revert:` means a prior change is being reverted in some way.
140140
* `test:` means only tests are being added.
141141

142+
For the body, follow this guidance:
143+
144+
* Briefly tells *why* the change is being made. This usually means
145+
briefly describing how a bug manifests or what can't be accomplished
146+
without the feature.
147+
* Briefly gives an overview of *how* the code is changed. This is to
148+
orient readers for the diff they're about to read and understand; it's
149+
not a verbatim description of what changed.
150+
* List unrelated or notable dev-only changes at the end. e.g. formatting an
151+
old file, cleaning up testing, adding test support code, etc.
152+
142153
For the full details of types, see
143154
[Conventional Commits](https://www.conventionalcommits.org/).
144155

156+
#### PR description example
157+
158+
```
159+
fix(pypi): handle files with .exe extensions
160+
161+
Currently, if a file with `.exe` is seen, an error
162+
occurs because validation assumes unix-only filenames.
163+
This prevents using whls with pre-built .exe files in
164+
their data payload.
165+
166+
To fix, detect the target OS and use an OS-appropriate
167+
validation function.
168+
169+
* Also adds test helpers for detecting the current OS
170+
```
171+
145172
### Documenting changes
146173

147174
Changes are documented in two places: CHANGELOG.md and API docs.

MODULE.bazel

Lines changed: 4 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ module(
66

77
bazel_dep(name = "bazel_features", version = "1.21.0")
88
bazel_dep(name = "bazel_skylib", version = "1.8.2")
9-
bazel_dep(name = "rules_cc", version = "0.1.5")
9+
bazel_dep(name = "package_metadata", version = "0.0.7")
1010
bazel_dep(name = "platforms", version = "0.0.11")
11+
bazel_dep(name = "rules_cc", version = "0.1.5")
1112

1213
# Those are loaded only when using py_proto_library
1314
# Use py_proto_library directly from protobuf repository
@@ -64,141 +65,6 @@ register_toolchains("@pythons_hub//:all")
6465
# Install twine for our own runfiles wheel publishing and allow bzlmod users to use it.
6566

6667
pip = use_extension("//python/extensions:pip.bzl", "pip")
67-
68-
# NOTE @aignas 2025-07-06: we define these platforms to keep backwards compatibility. Whilst we
69-
# stabilize the API this list may be updated with a mention in the CHANGELOG.
70-
[
71-
pip.default(
72-
arch_name = cpu,
73-
config_settings = [
74-
"@platforms//cpu:{}".format(cpu),
75-
"@platforms//os:linux",
76-
"//python/config_settings:_is_py_freethreaded_{}".format(
77-
"yes" if freethreaded else "no",
78-
),
79-
],
80-
env = {"platform_version": "0"},
81-
marker = "python_version >= '3.13'" if freethreaded else "",
82-
os_name = "linux",
83-
platform = "linux_{}{}".format(cpu, freethreaded),
84-
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
85-
"abi3",
86-
"cp{major}{minor}",
87-
],
88-
whl_platform_tags = [
89-
"linux_{}".format(cpu),
90-
"manylinux_*_{}".format(cpu),
91-
],
92-
)
93-
for cpu in [
94-
"x86_64",
95-
"aarch64",
96-
]
97-
for freethreaded in [
98-
"",
99-
"_freethreaded",
100-
]
101-
]
102-
103-
[
104-
pip.default(
105-
arch_name = cpu,
106-
config_settings = [
107-
"@platforms//cpu:{}".format(cpu),
108-
"@platforms//os:osx",
109-
"//python/config_settings:_is_py_freethreaded_{}".format(
110-
"yes" if freethreaded else "no",
111-
),
112-
],
113-
# We choose the oldest non-EOL version at the time when we release `rules_python`.
114-
# See https://endoflife.date/macos
115-
env = {"platform_version": "14.0"},
116-
marker = "python_version >= '3.13'" if freethreaded else "",
117-
os_name = "osx",
118-
platform = "osx_{}{}".format(cpu, freethreaded),
119-
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
120-
"abi3",
121-
"cp{major}{minor}",
122-
],
123-
whl_platform_tags = [
124-
"macosx_*_{}".format(suffix)
125-
for suffix in platform_tag_cpus
126-
],
127-
)
128-
for cpu, platform_tag_cpus in {
129-
"aarch64": [
130-
"universal2",
131-
"arm64",
132-
],
133-
"x86_64": [
134-
"universal2",
135-
"x86_64",
136-
],
137-
}.items()
138-
for freethreaded in [
139-
"",
140-
"_freethreaded",
141-
]
142-
]
143-
144-
[
145-
pip.default(
146-
arch_name = cpu,
147-
config_settings = [
148-
"@platforms//cpu:{}".format(cpu),
149-
"@platforms//os:windows",
150-
"//python/config_settings:_is_py_freethreaded_{}".format(
151-
"yes" if freethreaded else "no",
152-
),
153-
],
154-
env = {"platform_version": "0"},
155-
marker = "python_version >= '3.13'" if freethreaded else "",
156-
os_name = "windows",
157-
platform = "windows_{}{}".format(cpu, freethreaded),
158-
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
159-
"abi3",
160-
"cp{major}{minor}",
161-
],
162-
whl_platform_tags = whl_platform_tags,
163-
)
164-
for cpu, whl_platform_tags in {
165-
"x86_64": ["win_amd64"],
166-
}.items()
167-
for freethreaded in [
168-
"",
169-
"_freethreaded",
170-
]
171-
]
172-
173-
[
174-
pip.default(
175-
arch_name = cpu,
176-
config_settings = [
177-
"@platforms//cpu:{}".format(cpu),
178-
"@platforms//os:windows",
179-
"//python/config_settings:_is_py_freethreaded_{}".format(
180-
"yes" if freethreaded else "no",
181-
),
182-
],
183-
env = {"platform_version": "0"},
184-
marker = "python_version >= '3.13'" if freethreaded else "python_version >= '3.11'",
185-
os_name = "windows",
186-
platform = "windows_{}{}".format(cpu, freethreaded),
187-
whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else [
188-
"abi3",
189-
"cp{major}{minor}",
190-
],
191-
whl_platform_tags = whl_platform_tags,
192-
)
193-
for cpu, whl_platform_tags in {
194-
"aarch64": ["win_arm64"],
195-
}.items()
196-
for freethreaded in [
197-
"",
198-
"_freethreaded",
199-
]
200-
]
201-
20268
pip.parse(
20369
hub_name = "rules_python_publish_deps",
20470
python_version = "3.11",
@@ -246,6 +112,8 @@ use_repo(
246112
"somepkg_with_build_files",
247113
"whl_library_extras_direct_dep",
248114
"whl_with_build_files",
115+
"whl_with_data1",
116+
"whl_with_data2",
249117
)
250118

251119
dev_rules_python_config = use_extension(

docs/environment-variables.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,6 @@ When `1`, `rules_python` will warn users about deprecated functionality that wil
5252
be removed in a subsequent major `rules_python` version. Defaults to `0` if unset.
5353
:::
5454

55-
::::{envvar} RULES_PYTHON_ENABLE_PYSTAR
56-
57-
When `1`, the `rules_python` Starlark implementation of the core rules is used
58-
instead of the Bazel-builtin rules. Note that this requires Bazel 7+. Defaults
59-
to `1`.
60-
61-
:::{versionadded} 0.26.0
62-
Defaults to `0` if unspecified.
63-
:::
64-
:::{versionchanged} 0.40.0
65-
The default became `1` if unspecified
66-
:::
67-
::::
68-
69-
::::{envvar} RULES_PYTHON_ENABLE_PIPSTAR
70-
71-
When `1`, the `rules_python` Starlark implementation of the PyPI/pip integration is used
72-
instead of the legacy Python scripts.
73-
74-
:::{versionadded} 1.5.0
75-
:::
76-
:::{versionchanged} 1.7.0
77-
Flipped to be enabled by default.
78-
:::
79-
::::
80-
8155
::::{envvar} RULES_PYTHON_EXTRACT_ROOT
8256

8357
Directory to use as the root for creating files necessary for bootstrapping so
@@ -174,3 +148,14 @@ os, arch values are the same as the ones mentioned in the
174148

175149
When `1`, debug information about coverage behavior is printed to stderr.
176150
:::
151+
152+
## Removed Environment Variables
153+
154+
:::{versionremoved} VERSION_NEXT_FEATURE
155+
The following environment variables were removed:
156+
157+
* `RULES_PYTHON_ENABLE_PYSTAR`: Used to enable the Starlark implementation of
158+
core rules.
159+
* `RULES_PYTHON_ENABLE_PIPSTAR`: Used to enable the Starlark implementation of
160+
PyPI integration.
161+
:::

0 commit comments

Comments
 (0)