Skip to content

Commit a926550

Browse files
authored
Merge branch 'main' into isolated
2 parents c438551 + ad74ef7 commit a926550

126 files changed

Lines changed: 2486 additions & 1047 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.

.bazelci/presubmit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ buildifier:
3131
# As a regression test for #225, check that wheel targets still build when
3232
# their package path is qualified with the repo name.
3333
- "@rules_python//examples/wheel/..."
34-
build_flags:
34+
build_flags: &reusable_config_build_flags
35+
- "--experimental_repository_cache_hardlinks=false"
3536
- "--keep_going"
3637
- "--build_tag_filters=-integration-test"
3738
- "--verbose_failures"
@@ -42,6 +43,7 @@ buildifier:
4243
- "--test_tag_filters=-integration-test"
4344
.common_workspace_flags_min_bazel: &common_workspace_flags_min_bazel
4445
build_flags:
46+
- "--experimental_repository_cache_hardlinks=false"
4547
- "--noenable_bzlmod"
4648
- "--build_tag_filters=-integration-test"
4749
test_flags:
@@ -292,6 +294,7 @@ tasks:
292294
name: "RBE: Ubuntu, minimum Bazel"
293295
platform: rbe_ubuntu2204
294296
build_flags:
297+
- "--experimental_repository_cache_hardlinks=false"
295298
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
296299
# which prevents cc toolchain autodetection from working correctly
297300
# on Bazel 5.4 and earlier. To workaround this, manually specify the

.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ common --incompatible_use_plus_in_repo_names
3030
# See https://github.com/bazel-contrib/rules_python/issues/3655
3131
common --incompatible_strict_action_env=false
3232

33+
# To work around bug on bazel 7
34+
common:ci --experimental_repository_cache_hardlinks=false
35+
3336
# Windows makes use of runfiles for some rules
3437
build --enable_runfiles
3538

@@ -39,6 +42,7 @@ common --enable_bzlmod
3942
# Local disk cache greatly speeds up builds if the regular cache is lost
4043
common --disk_cache=~/.cache/bazel/bazel-disk-cache
4144

45+
4246
# Additional config to use for readthedocs builds.
4347
# See .readthedocs.yml for additional flags that can only be determined from
4448
# the runtime environment.
@@ -50,3 +54,7 @@ common --incompatible_python_disallow_native_rules
5054
common --incompatible_no_implicit_file_export
5155

5256
build --lockfile_mode=update
57+
58+
import %workspace%/specialized_configs.bazelrc
59+
60+
try-import user.bazelrc

.bazelrc.deleted_packages

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ common --deleted_packages=examples/multi_python_versions/requirements
1717
common --deleted_packages=examples/multi_python_versions/tests
1818
common --deleted_packages=examples/pip_parse
1919
common --deleted_packages=examples/pip_parse_vendored
20-
common --deleted_packages=examples/pip_repository_annotations
2120
common --deleted_packages=gazelle
2221
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation
2322
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg

.github/workflows/mypy.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ jobs:
2121
- uses: actions/checkout@v6
2222
- uses: jpetrucciani/mypy-check@master
2323
with:
24-
requirements: 1.6.0
25-
python_version: 3.9
2624
path: 'python/runfiles'
2725
- uses: jpetrucciani/mypy-check@master
2826
with:
29-
requirements: 1.6.0
30-
python_version: 3.9
3127
path: 'tests/runfiles'

CHANGELOG.md

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,55 @@ BEGIN_UNRELEASED_TEMPLATE
4747
END_UNRELEASED_TEMPLATE
4848
-->
4949

50-
{#v0-0-0}
51-
## Unreleased
50+
{#v2-0-0}
51+
## [2.0.0] - 2026-04-09
5252

53-
[0.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.0.0
53+
[2.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/2.0.0
5454

55-
{#v0-0-0-removed}
55+
{#v2-0-0-removed}
5656
### Removed
5757
* Nothing removed.
5858

59-
{#v0-0-0-changed}
59+
{#v2-0-0-changed}
6060
### Changed
6161

6262
**Breaking**
6363
* {obj}`--windows_enable_symlinks` is required. Add `startup
6464
--windows_enable_symlinks` to your `.bazelrc` to enable Bazel using full
6565
symlink support on Windows.
66+
* venv-based binaries are created by default ({obj}`--bootstrap_impl=system_python`)
67+
on supported platforms (Linux/Mac with Bazel 8+, or Windows).
68+
* `--build_python_zip` on Windows is ignored. Use {obj}`py_zipapp_binary` to create
69+
zips of Python programs.
70+
* (pypi) Previously `experimental_index_url` users would not need to specify
71+
target platforms if cross-building is required. From now we will only pull
72+
wheels for the host OS to better align with how the rules work with the legacy
73+
`pip` implementation. Use {obj}`pip.parse.target_platforms` to customize the
74+
behavior.
75+
Related to [#260](https://github.com/bazel-contrib/rules_python/issues/260).
6676

6777
Other changes:
6878
* (pypi) Update dependencies used for `compile_pip_requirements`, building
6979
sdists in the `whl_library` rule and fetching wheels using `pip`.
70-
71-
{#v0-0-0-fixed}
80+
* (pypi) Before using the bazel downloader to fetch the PyPI package metadata
81+
we will from now on fetch the lists of available packages on each index. The
82+
used package mappings will be written as facts to the `MODULE.bazel.lock` file
83+
on supported bazel versions and it should be done at most once. As a result,
84+
per-package {obj}`experimental_index_url_overrides` is no longer needed . What
85+
is more, the flags for `--index_url` and `--extra-index-url` now behave in the
86+
same way as in `uv` or `pip`, i.e. we default to `--index-url` if the package
87+
is not found in `--extra-index-url`. Fixes
88+
([#3260](https://github.com/bazel-contrib/rules_python/issues/3260) and
89+
[#2632](https://github.com/bazel-contrib/rules_python/issues/2632)).
90+
* (uv) We will now use the download URL specified in the `uv`'s
91+
`dist_manifest.json` file. If you have redirects or blocking rules as part of
92+
your downloader setup, you may need to adjust them. What is more, the default
93+
uv version has been bumped `0.11.2`.
94+
* (runfiles): Type annotations are no longer tested for Python 3.9.
95+
* Windows no longer defaults to creating a zip file and extracting it; a
96+
symlink-based runfiles tree is created, as on unix-like platforms.
97+
98+
{#v2-0-0-fixed}
7299
### Fixed
73100
* (toolchain) Also set Make variables for local toolchains.
74101
* (zipapp) Resolve issue passing through compression settings in
@@ -83,15 +110,51 @@ Other changes:
83110
* (bootstrap) Fixed incorrect runfiles path construction in bootstrap
84111
scripts when binary is defined in another bazel module
85112
([#3563](https://github.com/bazel-contrib/rules_python/issues/3563)).
113+
* (bootstrap) Resolve `RUNFILES_DIR` inheritance issues, which lead to a child
114+
Python binary incorrectly using it's parent's Python binary environment
115+
([#3518](https://github.com/bazel-contrib/rules_python/issues/3518)).
116+
* (uv) Downloads for versions `>=0.10` work again. In order to fix this we had
117+
drop support for `powerpc64` platform. People interested in the platform can
118+
bring it back via the `uv.default` API. Like:
119+
```
120+
uv.default(
121+
compatible_with = [
122+
"@platforms//os:linux",
123+
"@platforms//cpu:ppc",
124+
],
125+
platform = "powerpc64-unknown-linux-gnu",
126+
)
127+
```
128+
Fixes [#3676](https://github.com/bazel-contrib/rules_python/issues/3676).
86129

87-
{#v0-0-0-added}
130+
{#v2-0-0-added}
88131
### Added
89132
* (pypi) Write SimpleAPI contents to the `MODULE.bazel.lock` file if using
90-
{obj}`experimental_index_url` which should speed up consecutive initializations and should no
91-
longer require the network access if the cache is hydrated.
92-
Implements [#2731](https://github.com/bazel-contrib/rules_python/issues/2731).
133+
{obj}`experimental_index_url` which should speed up consecutive
134+
initializations and should no longer require the network access if the cache is
135+
hydrated. Implements
136+
[#2731](https://github.com/bazel-contrib/rules_python/issues/2731).
137+
* (pypi) The `--index-url` and `--extra-index-url` is now parsed from the lock
138+
file and the {obj}`pip.parse.experimental_index_url` and
139+
{obj}`pip.parse.experimental_extra_index_urls` is
140+
no longer mandatory to leverage the bazel downloader.
141+
Implements
142+
[#1357](https://github.com/bazel-contrib/rules_python/issues/1357),
143+
[#2951](https://github.com/bazel-contrib/rules_python/issues/2951).
144+
* (pypi) If cross-compilation is needed, use the {obj}`pip.parse.target_platforms`
145+
to specify exactly which platforms should be supported.
146+
Implements
147+
[#260](https://github.com/bazel-contrib/rules_python/issues/260).
93148
* (wheel) Specifying a path ending in `/` as a destination in `data_files`
94149
will now install file(s) to a folder, preserving their basename.
150+
* Various attributes and fields added to support venvs on Windows:
151+
* {obj}`py_runtime.venv_bin_files` and {obj}`PyRuntime.venv_binfiles`
152+
field added to specify additional Python runtime files Windows needs for
153+
venvs.
154+
* {obj}`PyExecutableInfo.venv_interpreter_runfiles`, and
155+
{obj}`PyExecutableInfo.venv_interpreter_symlinks` adde
156+
* (wheel) Add support for `add_path_prefix` argument in `py_wheel` which can be
157+
used to prepend a prefix to the files in the wheel.
95158

96159
{#v1-9-0}
97160
## [1.9.0] - 2026-02-21

MODULE.bazel

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ register_toolchains("@pythons_hub//:all")
6565

6666
pip = use_extension("//python/extensions:pip.bzl", "pip")
6767

68-
# NOTE @aignas 2025-07-06: we define these platforms to keep backwards compatibility with the
69-
# current `experimental_index_url` implementation. Whilst we stabilize the API this list may be
70-
# updated with a mention in the CHANGELOG.
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.
7170
[
7271
pip.default(
7372
arch_name = cpu,
@@ -223,7 +222,7 @@ bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
223222
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
224223
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
225224
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
226-
bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)
225+
bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True)
227226
bazel_dep(name = "other", version = "0", dev_dependency = True)
228227
bazel_dep(name = "another_module", version = "0", dev_dependency = True)
229228

@@ -306,7 +305,6 @@ dev_pip = use_extension(
306305
[
307306
dev_pip.parse(
308307
download_only = True,
309-
experimental_index_url = "https://pypi.org/simple",
310308
hub_name = "dev_pip",
311309
parallel_download = False,
312310
python_version = python_version,
@@ -329,7 +327,6 @@ dev_pip = use_extension(
329327

330328
dev_pip.parse(
331329
download_only = True,
332-
experimental_index_url = "https://pypi.org/simple",
333330
hub_name = "pypiserver",
334331
python_version = "3.11",
335332
requirements_lock = "//examples/wheel:requirements_server.txt",
@@ -385,7 +382,7 @@ uv = use_extension("//python/uv:uv.bzl", "uv")
385382
uv.default(
386383
base_url = "https://github.com/astral-sh/uv/releases/download",
387384
manifest_filename = "dist-manifest.json",
388-
version = "0.6.3",
385+
version = "0.11.2",
389386
)
390387
uv.default(
391388
compatible_with = [
@@ -401,13 +398,6 @@ uv.default(
401398
],
402399
platform = "aarch64-unknown-linux-gnu",
403400
)
404-
uv.default(
405-
compatible_with = [
406-
"@platforms//os:linux",
407-
"@platforms//cpu:ppc",
408-
],
409-
platform = "powerpc64-unknown-linux-gnu",
410-
)
411401
uv.default(
412402
compatible_with = [
413403
"@platforms//os:linux",
@@ -460,7 +450,7 @@ uv_dev = use_extension(
460450
dev_dependency = True,
461451
)
462452
uv_dev.configure(
463-
version = "0.6.2",
453+
version = "0.11.2",
464454
)
465455

466456
# Temporarily comment out these flag aliases because they break Bazel 9

docs/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ sphinx_docs(
7373
":bzl_api_docs",
7474
":py_api_srcs",
7575
":py_runtime_pair",
76-
"@sphinxdocs//sphinxdocs/docs:docs_lib",
76+
"@sphinxdocs//docs:docs_lib",
7777
],
7878
)
7979

docs/pypi/download.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ the years, people started needing support for building containers, and usually,
104104
fetching dependencies for a particular target platform that may be different from the host
105105
platform.
106106

107-
Multi-platform support for cross-building the wheels can be done in two ways:
108-
1. using {attr}`experimental_index_url` for the {bzl:obj}`pip.parse` bzlmod tag class
109-
2. using the {attr}`pip.parse.download_only` setting.
107+
Multi-platform support for cross-building the wheels can be done by
108+
using {attr}`target_platforms` for the {bzl:obj}`pip.parse` bzlmod tag class
110109

111110
:::{warning}
112111
This will not work for sdists with C extensions, but pure Python sdists may still work using the first
@@ -207,16 +206,6 @@ additional keys, which become available during dependency evaluation.
207206
(bazel-downloader)=
208207
### Bazel downloader and multi-platform wheel hub repository.
209208

210-
:::{warning}
211-
This is currently still experimental, and whilst it has been proven to work in quite a few
212-
environments, the APIs are still being finalized, and there may be changes to the APIs for this
213-
feature without much notice.
214-
215-
The issues that you can subscribe to for updates are:
216-
* {gh-issue}`260`
217-
* {gh-issue}`1357`
218-
:::
219-
220209
The {obj}`pip` extension supports pulling information from `PyPI` (or a compatible mirror), and it
221210
will ensure that the [bazel downloader][bazel_downloader] is used for downloading the wheels.
222211

@@ -228,14 +217,10 @@ This provides the following benefits:
228217
* Allow using transitions and targeting free-threaded and musl platforms more easily.
229218
* Avoids `pip` for wheel fetching and results in much faster dependency fetching.
230219

231-
To enable the feature specify {attr}`pip.parse.experimental_index_url` as shown in
232-
the {gh-path}`examples/bzlmod/MODULE.bazel` example.
233-
234-
Similar to [uv](https://docs.astral.sh/uv/configuration/indexes/), one can override the
235-
index that is used for a single package. By default, we first search in the index specified by
236-
{attr}`pip.parse.experimental_index_url`, then we iterate through the
237-
{attr}`pip.parse.experimental_extra_index_urls` unless there are overrides specified via
238-
{attr}`pip.parse.experimental_index_url_overrides`.
220+
Similar to [uv](https://docs.astral.sh/uv/configuration/indexes/), one can override the index that
221+
is used for a single package. By default, we first search in the indexes specified by
222+
`--extra-index-url`, then we fall back to the `--index-url` setting unless there are overrides
223+
specified via {attr}`pip.parse.experimental_index_url_overrides`.
239224

240225
When using this feature during the `pip` extension evaluation you will see the accessed indexes similar to below:
241226
```console

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ readthedocs-sphinx-ext==2.2.5 \
359359
--hash=sha256:ee5fd5b99db9f0c180b2396cbce528aa36671951b9526bb0272dbfce5517bd27 \
360360
--hash=sha256:f8c56184ea011c972dd45a90122568587cc85b0127bc9cf064d17c68bc809daa
361361
# via rules-python-docs (docs/pyproject.toml)
362-
requests==2.32.5 \
363-
--hash=sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6 \
364-
--hash=sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf
362+
requests==2.33.0 \
363+
--hash=sha256:3324635456fa185245e24865e810cecec7b4caf933d7eb133dcde67d48cee69b \
364+
--hash=sha256:c7ebc5e8b0f21837386ad0e1c8fe8b829fa5f544d8df3b2253bff14ef29d7652
365365
# via
366366
# readthedocs-sphinx-ext
367367
# sphinx

examples/bzlmod/MODULE.bazel

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,6 @@ pip.default(
183183
pip.parse(
184184
# We can use `envsubst in the above
185185
envsubst = ["PIP_INDEX_URL"],
186-
# Use the bazel downloader to query the simple API for downloading the sources
187-
# Note, that we can use envsubst for this value.
188-
experimental_index_url = "${PIP_INDEX_URL:-https://pypi.org/simple}",
189-
# One can also select a particular index for a particular package.
190-
# This ensures that the setup is resistant against confusion attacks.
191-
# experimental_index_url_overrides = {
192-
# "my_package": "https://different-index-url.com",
193-
# },
194-
# Or you can specify extra indexes like with `pip`:
195-
# experimental_extra_index_urls = [
196-
# "https://different-index-url.com",
197-
# ],
198186
experimental_requirement_cycles = {
199187
"sphinx": [
200188
"sphinx",
@@ -208,6 +196,16 @@ pip.parse(
208196
extra_hub_aliases = {
209197
"wheel": ["generated_file"],
210198
},
199+
extra_pip_args = [
200+
# Use the bazel downloader to query the simple API for downloading the sources
201+
# Note, that we can use envsubst for this value.
202+
# One can also select a particular index for a particular package.
203+
# This ensures that the setup is resistant against confusion attacks.
204+
# experimental_index_url_overrides = {
205+
# "my_package": "https://different-index-url.com",
206+
# },
207+
"--index-url=${PIP_INDEX_URL:-https://pypi.org/simple}",
208+
],
211209
hub_name = "pip",
212210
python_version = "3.9",
213211
requirements_lock = "requirements_lock_3_9.txt",

0 commit comments

Comments
 (0)