Skip to content

Commit e5c9230

Browse files
committed
Merge remote-tracking branch 'upstream/main' into remove-cc-defs
2 parents 5d866a3 + 317dab4 commit e5c9230

File tree

13 files changed

+170
-70
lines changed

13 files changed

+170
-70
lines changed

.bazelci/presubmit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ tasks:
177177
<<: *minimum_supported_version
178178
<<: *reusable_config
179179
name: "RBE: Ubuntu, minimum Bazel"
180-
platform: rbe_ubuntu1604
180+
platform: rbe_ubuntu2004
181181
build_flags:
182182
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
183183
# which prevents cc toolchain autodetection from working correctly
@@ -195,7 +195,7 @@ tasks:
195195
rbe:
196196
<<: *reusable_config
197197
name: "RBE: Ubuntu"
198-
platform: rbe_ubuntu1604
198+
platform: rbe_ubuntu2004
199199
test_flags:
200200
- "--test_tag_filters=-integration-test,-acceptance-test"
201201
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"

BZLMOD_SUPPORT.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
## `rules_python` `bzlmod` support
44

5-
- Status: Beta
5+
- Status: GA
66
- Full Feature Parity: No
7+
- `rules_python`: Yes
8+
- `rules_python_gazelle_plugin`: No (see below).
79

8-
Some features are missing or broken, and the public APIs are not yet stable.
10+
In general `bzlmod` has more features than `WORKSPACE` and users are encouraged to migrate.
911

1012
## Configuration
1113

@@ -27,15 +29,6 @@ A user does not use `local_path_override` stanza and would define the version in
2729

2830
A second example, in [examples/bzlmod_build_file_generation](examples/bzlmod_build_file_generation) demonstrates the use of `bzlmod` to configure `gazelle` support for `rules_python`.
2931

30-
## Feature parity
31-
32-
This rule set does not have full feature partity with the older `WORKSPACE` type configuration:
33-
34-
1. Gazelle does not support finding deps in sub-modules. For instance we can have a dep like ` "@our_other_module//other_module/pkg:lib",` in a `py_test` definition.
35-
2. We have some features that are still not fully flushed out, and the user interface may change.
36-
37-
Check ["issues"](/bazelbuild/rules_python/issues) for an up to date list.
38-
3932
## Differences in behavior from WORKSPACE
4033

4134
### Default toolchain is not the local system Python
@@ -52,10 +45,35 @@ platforms.
5245
If you want to use the same toolchain as what WORKSPACE used, then manually
5346
register the builtin Bazel Python toolchain by doing
5447
`register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")`.
55-
**IMPORTANT: this should only be done in a root module, and may intefere with
48+
49+
Note that using this builtin Bazel toolchain is deprecated and unsupported.
50+
See the {obj}`runtime_env_toolchains` docs for a replacement that is marginally
51+
better supported.
52+
**IMPORTANT: this should only be done in a root module, and may interfere with
5653
the toolchains rules_python registers**.
5754

5855
NOTE: Regardless of your toolchain, due to
5956
[#691](https://github.com/bazelbuild/rules_python/issues/691), `rules_python`
6057
still relies on a local Python being available to bootstrap the program before
6158
handing over execution to the toolchain Python.
59+
60+
To override this behaviour see {obj}`--bootstrap_impl=script`, which switches
61+
to `bash`-based bootstrap on UNIX systems.
62+
63+
### Better PyPI package downloading on bzlmod
64+
65+
On `bzlmod` users have the option to use the `bazel_downloader` to download packages
66+
and work correctly when `host` platform is not the same as the `target` platform. This
67+
provides faster package download times and integration with the credentials helper.
68+
69+
### Extra targets in `whl_library` repos
70+
71+
Due to how `bzlmod` is designed and the visibility rules that it enforces, it is best to use
72+
the targets in the `whl` repos as they do not rely on using the `annotations` API to
73+
add extra targets to so-called `spoke` repos. For alternatives that should cover most of the
74+
existing usecases please see:
75+
* {bzl:obj}`py_console_script_binary` to create `entry_point` targets.
76+
* {bzl:obj}`whl_filegroup` to extract filegroups from the `whl` targets (e.g. `@pip//numpy:whl`)
77+
* {bzl:obj}`pip.override` to patch the downloaded `whl` files. Using that you
78+
can change the `METADATA` of the `whl` file that will influence how
79+
`rules_python` code generation behaves.

CHANGELOG.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,33 @@ A brief description of the categories of changes:
2020
* Particular sub-systems are identified using parentheses, e.g. `(bzlmod)` or
2121
`(docs)`.
2222

23+
{#v0-0-0}
2324
## Unreleased
2425

26+
[0.0.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.0.0
27+
28+
{#v0-0-0-changed}
2529
### Changed
2630
- Nothing yet
2731

32+
{#v0-0-0-fixed}
2833
### Fixed
2934
- Nothing yet
3035

36+
{#v0-0-0-added}
3137
### Added
3238
- Nothing yet
3339

40+
{#v0-0-0-removed}
3441
### Removed
3542
- Nothing yet
3643

44+
{#v0-37-0}
3745
## [0.37.0] - 2024-10-18
3846

39-
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.0
47+
[0.37.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.0
4048

49+
{#v0-37-0-changed}
4150
### Changed
4251
* **BREAKING** `py_library` no longer puts its source files or generated pyc
4352
files in runfiles; it's the responsibility of consumers (e.g. binaries) to
@@ -54,6 +63,7 @@ A brief description of the categories of changes:
5463
{obj}`--@rules_python//python/config_settings:exec_tools_toolchain=disabled`.
5564
* (deps) stardoc 0.6.2 added as dependency.
5665

66+
{#v0-37-0-fixed}
5767
### Fixed
5868
* (bzlmod) The `python.override(minor_mapping)` now merges the default and the
5969
overridden versions ensuring that the resultant `minor_mapping` will always
@@ -84,6 +94,7 @@ A brief description of the categories of changes:
8494
outside of the `//:BUILD.bazel` file.
8595
Fixes [#2299](https://github.com/bazelbuild/rules_python/issues/2299).
8696

97+
{#v0-37-0-added}
8798
### Added
8899
* (py_wheel) Now supports `compress = (True|False)` to allow disabling
89100
compression to speed up development.
@@ -107,17 +118,20 @@ A brief description of the categories of changes:
107118

108119
[20241008]: https://github.com/indygreg/python-build-standalone/releases/tag/20241008
109120

121+
{#v0-37-0-removed}
110122
### Removed
111123
* (precompiling) {obj}`--precompile_add_to_runfiles` has been removed.
112124
* (precompiling) {obj}`--pyc_collection` has been removed. The `pyc_collection`
113125
attribute now bases its default on {obj}`--precompile`.
114126
* (precompiling) The {obj}`precompile=if_generated_source` value has been removed.
115127
* (precompiling) The {obj}`precompile_source_retention=omit_if_generated_source` value has been removed.
116128

129+
{#v0-36-0}
117130
## [0.36.0] - 2024-09-24
118131

119132
[0.36.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.36.0
120133

134+
{#v0-36-0-changed}
121135
### Changed
122136
* (gazelle): Update error messages when unable to resolve a dependency to be more human-friendly.
123137
* (flags) The {obj}`--python_version` flag now also returns
@@ -135,6 +149,7 @@ A brief description of the categories of changes:
135149
available.
136150
* (bazel) Minimum bazel 7 version that we test against has been bumped to `7.1`.
137151

152+
{#v0-36-0-fixed}
138153
### Fixed
139154
* (whl_library): Remove `--no-index` and add `--no-build-isolation` to the
140155
`pip install` command when installing a wheel from a local file, which happens
@@ -161,6 +176,7 @@ A brief description of the categories of changes:
161176
* (toolchain) The {bzl:obj}`gen_python_config_settings` has been fixed to include
162177
the flag_values from the platform definitions.
163178

179+
{#v0-36-0-added}
164180
### Added
165181
* (bzlmod): Toolchain overrides can now be done using the new
166182
{bzl:obj}`python.override`, {bzl:obj}`python.single_version_override` and
@@ -182,15 +198,18 @@ A brief description of the categories of changes:
182198
* (toolchains) Added `//python:none`, a special target for use with
183199
{obj}`py_exec_tools_toolchain.exec_interpreter` to treat the value as `None`.
184200

201+
{#v0-36-0-removed}
185202
### Removed
186203
* (toolchains): Removed accidentally exposed `http_archive` symbol from
187204
`python/repositories.bzl`.
188205
* (toolchains): An internal _is_python_config_setting_ macro has been removed.
189206

207+
{#v0-35-0}
190208
## [0.35.0] - 2024-08-15
191209

192210
[0.35.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.35.0
193211

212+
{#v0-35-0-changed}
194213
### Changed
195214
* (whl_library) A better log message when the wheel is built from an sdist or
196215
when the wheel is downloaded using `download_only` feature to aid debugging.
@@ -204,6 +223,7 @@ A brief description of the categories of changes:
204223
disabling it (Requires {obj}`--bootstrap_impl=script`)
205224
([#2060](https://github.com/bazelbuild/rules_python/issues/2060)).
206225

226+
{#v0-35-0-fixed}
207227
### Fixed
208228
* (rules) `compile_pip_requirements` now sets the `USERPROFILE` env variable on
209229
Windows to work around an issue where `setuptools` fails to locate the user's
@@ -245,6 +265,7 @@ A brief description of the categories of changes:
245265
in the same directory as the main file.
246266
Fixes [#1631](https://github.com/bazelbuild/rules_python/issues/1631).
247267

268+
{#v0-35-0-added}
248269
### Added
249270
* (rules) `compile_pip_requirements` supports multiple requirements input files as `srcs`.
250271
* (rules) `PYTHONSAFEPATH` is inherited from the calling environment to allow
@@ -268,10 +289,12 @@ A brief description of the categories of changes:
268289
[pytest_bazel]: https://pypi.org/project/pytest-bazel
269290
[20240726]: https://github.com/indygreg/python-build-standalone/releases/tag/20240726
270291

292+
{#v0-34-0}
271293
## [0.34.0] - 2024-07-04
272294

273295
[0.34.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.34.0
274296

297+
{#v0-34-0-changed}
275298
### Changed
276299
* `protobuf`/`com_google_protobuf` dependency bumped to `v24.4`
277300
* (bzlmod): optimize the creation of config settings used in pip to
@@ -283,6 +306,7 @@ A brief description of the categories of changes:
283306
replaced by {obj}`//python/runtime_env_toolchains:all`. The old target will be
284307
removed in a future release.
285308

309+
{#v0-34-0-fixed}
286310
### Fixed
287311
* (bzlmod): When using `experimental_index_url` the `all_requirements`,
288312
`all_whl_requirements` and `all_data_requirements` will now only include
@@ -313,39 +337,47 @@ A brief description of the categories of changes:
313337
* (rules) The first element of the default outputs is now the executable again.
314338
* (pip) Fixed crash when pypi packages lacked a sha (e.g. yanked packages)
315339

340+
{#v0-34-0-added}
316341
### Added
317342
* (toolchains) {obj}`//python/runtime_env_toolchains:all`, which is a drop-in
318343
replacement for the "autodetecting" toolchain.
319344
* (gazelle) Added new `python_label_convention` and `python_label_normalization` directives. These directive
320345
allows altering default Gazelle label format to third-party dependencies useful for re-using Gazelle plugin
321346
with other rules, including `rules_pycross`. See [#1939](https://github.com/bazelbuild/rules_python/issues/1939).
322347

348+
{#v0-34-0-removed}
323349
### Removed
324350
* (pip): Removes the `entrypoint` macro that was replaced by `py_console_script_binary` in 0.26.0.
325351

352+
{#v0-33-2}
326353
## [0.33.2] - 2024-06-13
327354

328355
[0.33.2]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.2
329356

357+
{#v0-33-2-fixed}
330358
### Fixed
331359
* (toolchains) The {obj}`exec_tools_toolchain_type` is disabled by default.
332360
To enable it, set {obj}`--//python/config_settings:exec_tools_toolchain=enabled`.
333361
This toolchain must be enabled for precompilation to work. This toolchain will
334362
be enabled by default in a future release.
335363
Fixes [#1967](https://github.com/bazelbuild/rules_python/issues/1967).
336364

365+
{#v0-33-1}
337366
## [0.33.1] - 2024-06-13
338367

339368
[0.33.1]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.1
340369

370+
{#v0-33-1-fixed}
341371
### Fixed
342372
* (py_binary) Fix building of zip file when using `--build_python_zip`
343373
argument. Fixes [#1954](https://github.com/bazelbuild/rules_python/issues/1954).
344374

375+
{#v0-33-0}
345376
## [0.33.0] - 2024-06-12
346377

347378
[0.33.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.0
348379

380+
{#v0-33-0-changed}
349381
### Changed
350382
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
351383
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
@@ -374,6 +406,7 @@ A brief description of the categories of changes:
374406
`python_{version}_host` keys if you would like to have access to a Python
375407
interpreter that can be used in a repository rule context.
376408

409+
{#v0-33-0-fixed}
377410
### Fixed
378411
* (gazelle) Remove `visibility` from `NonEmptyAttr`.
379412
Now empty(have no `deps/main/srcs/imports` attr) `py_library/test/binary` rules will
@@ -406,6 +439,7 @@ A brief description of the categories of changes:
406439
* (doc) Fix the `WORKSPACE` requirement vendoring example. Fixes
407440
[#1918](https://github.com/bazelbuild/rules_python/issues/1918).
408441

442+
{#v0-33-0-added}
409443
### Added
410444
* (rules) Precompiling Python source at build time is available. but is
411445
disabled by default, for now. Set
@@ -459,21 +493,25 @@ A brief description of the categories of changes:
459493

460494
[precompile-docs]: /precompiling
461495

496+
{#v0-32-2}
462497
## [0.32.2] - 2024-05-14
463498

464499
[0.32.2]: https://github.com/bazelbuild/rules_python/releases/tag/0.32.2
465500

501+
{#v0-32-2-fixed}
466502
### Fixed
467503

468504
* Workaround existence of infinite symlink loops on case insensitive filesystems when targeting linux platforms with recent Python toolchains. Works around an upstream [issue][indygreg-231]. Fixes [#1800][rules_python_1800].
469505

470506
[indygreg-231]: https://github.com/indygreg/python-build-standalone/issues/231
471507
[rules_python_1800]: https://github.com/bazelbuild/rules_python/issues/1800
472508

509+
{#v0-32-0}
473510
## [0.32.0] - 2024-05-12
474511

475512
[0.32.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.32.0
476513

514+
{#v0-32-0-changed}
477515
### Changed
478516

479517
* (bzlmod): The `MODULE.bazel.lock` `whl_library` rule attributes are now

CONTRIBUTING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,13 @@ The general process is:
194194
of. The API for the control mechanism can be removed in this release.
195195

196196
Note that the `+1` and `+2` releases are just examples; the steps are not
197-
required to happen in immedially subsequent releases.
197+
required to happen in immediately subsequent releases.
198198

199+
Once The first major version is released, the process will be:
200+
1. In `N.M.0` we introduce the new behaviour, but it is disabled by a feature flag.
201+
2. In `N.M+1.0` we may choose the behaviour to become the default if it is not too
202+
disruptive.
203+
3. In `N+1.0.0` we get rid of the old behaviour.
199204

200205
### How to control breaking changes
201206

0 commit comments

Comments
 (0)