1:::{default-domain} bzl 2::: 3 4# rules_python Changelog 5 6This is a human-friendly changelog in a keepachangelog.com style format. 7Because this changelog is for end-user consumption of meaningful changes,only 8a summary of a release's changes is described. This means every commit is not 9necessarily mentioned, and internal refactors or code cleanups are omitted 10unless they're particularly notable. 11 12A brief description of the categories of changes: 13 14* `Changed`: Some behavior changed. If the change is expected to break a 15 public API or supported behavior, it will be marked as **BREAKING**. Note that 16 beta APIs will not have breaking API changes called out. 17* `Fixed`: A bug, or otherwise incorrect behavior, was fixed. 18* `Added`: A new feature, API, or behavior was added in a backwards compatible 19 manner. 20* Particular sub-systems are identified using parentheses, e.g. `(bzlmod)` or 21 `(docs)`. 22 23<!-- 24Unreleased changes template. 25 26{#v0-0-0} 27## Unreleased 28 29[0.0.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.0.0 30 31{#v0-0-0-changed} 32### Changed 33* Nothing changed. 34 35{#v0-0-0-fixed} 36### Fixed 37* Nothing fixed. 38 39{#v0-0-0-added} 40### Added 41* Nothing added. 42 43{#v0-0-0-removed} 44### Removed 45* Nothing removed. 46--> 47 48{#v0-0-0} 49## Unreleased 50 51[0.0.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.0.0 52 53{#v0-0-0-changed} 54### Changed 55* Nothing changed. 56 57{#v0-0-0-fixed} 58### Fixed 59* Nothing fixed. 60 61{#v0-0-0-added} 62### Added 63* Nothing added. 64 65{#v0-0-0-removed} 66### Removed 67* Nothing removed. 68 69{#v1-0-0} 70## [1.0.0] - 2024-12-05 71 72[1.0.0]: https://github.com/bazelbuild/rules_python/releases/tag/1.0.0 73 74{#v1-0-0-changed} 75### Changed 76 77**Breaking**: 78* (toolchains) stop exposing config settings in python toolchain alias repos. 79 Please consider depending on the flags defined in 80 `//python/config_setting/...` and the `@platforms` package instead. 81* (toolchains) consumers who were depending on the `MACOS_NAME` and the `arch` 82 attribute in the `PLATFORMS` list, please update your code to respect the new 83 values. The values now correspond to the values available in the 84 `@platforms//` package constraint values. 85* (toolchains) `host_platform` and `interpreter` constants are no longer created 86 in the `toolchain` generated alias `.bzl` files. If you need to access the 87 host interpreter during the `repository_rule` evaluation, please use the 88 `@python_{version}_host//:python` targets created by 89 {bzl:obj}`python_register_toolchains` and 90 {bzl:obj}`python_register_multi_toolchains` macros or the {bzl:obj}`python` 91 bzlmod extension. 92* (bzlmod) `pip.parse.parse_all_requirements_files` attribute has been removed. 93 See notes in the previous versions about what to do. 94* (deps) rules_cc 0.1.0 (workspace) and 0.0.16 (bzlmod). 95* (deps) protobuf 29.0-rc2 (workspace; bzlmod already specifying that version). 96 97Other changes: 98* (python_repository) Start honoring the `strip_prefix` field for `zstd` archives. 99* (pypi) {bzl:obj}`pip_parse.extra_hub_aliases` now works in WORKSPACE files. 100* (binaries/tests) For {obj}`--bootstrap_impl=script`, a binary-specific (but 101 otherwise empty) virtual env is used to customize `sys.path` initialization. 102* (deps) bazel_skylib 1.7.0 (workspace; bzlmod already specifying that version) 103* (deps) bazel_features 1.21.0; necessary for compatiblity with Bazel 8 rc3 104* (deps) stardoc 0.7.2 to support Bazel 8. 105 106{#v1-0-0-fixed} 107### Fixed 108* (toolchains) stop depending on `uname` to get the value of the host platform. 109* (pypi): Correctly handle multiple versions of the same package in the requirements 110 files which is useful when including different PyTorch builds (e.g. <pytorch+cpu> vs <pytorch+cu118> ) for different target platforms. 111 Fixes ([2337](https://github.com/bazelbuild/rules_python/issues/2337)). 112* (uv): Correct the sha256sum for the `uv` binary for aarch64-apple-darwin. 113 Fixes ([2411](https://github.com/bazelbuild/rules_python/issues/2411)). 114* (binaries/tests) ({obj}`--bootstrap_impl=scipt`) Using `sys.executable` will 115 use the same `sys.path` setup as the calling binary. 116 ([2169](https://github.com/bazelbuild/rules_python/issues/2169)). 117* (workspace) Corrected protobuf's name to com_google_protobuf, the name is 118 hardcoded in Bazel, WORKSPACE mode. 119* (pypi): {bzl:obj}`compile_pip_requirements` no longer fails on Windows when `--enable_runfiles` is not enabled. 120* (pypi): {bzl:obj}`compile_pip_requirements` now correctly updates files in the source tree on Windows when `--windows_enable_symlinks` is not enabled. 121* (repositories): Add libs/python3.lib and pythonXY.dll to the `libpython` target 122 defined by a repository template. This enables stable ABI builds of Python extensions 123 on Windows (by defining Py_LIMITED_API). 124* (rules) `py_test` and `py_binary` targets no longer incorrectly remove the 125 first `sys.path` entry when using {obj}`--bootstrap_impl=script` 126 127{#v1-0-0-added} 128### Added 129* (gazelle): Parser failures will now be logged to the terminal. Additional 130 details can be logged by setting `RULES_PYTHON_GAZELLE_VERBOSE=1`. 131* (toolchains) allow users to select which variant of the support host toolchain 132 they would like to use through 133 `RULES_PYTHON_REPO_TOOLCHAIN_{VERSION}_{OS}_{ARCH}` env variable setting. For 134 example, this allows one to use `freethreaded` python interpreter in the 135 `repository_rule` to build a wheel from `sdist`. 136* (toolchain) The python interpreters targeting `muslc` libc have been added 137 for the latest toolchain versions for each minor Python version. You can control 138 the toolchain selection by using the 139 {bzl:obj}`//python/config_settings:py_linux_libc` build flag. 140* (providers) Added {obj}`py_runtime_info.site_init_template` and 141 {obj}`PyRuntimeInfo.site_init_template` for specifying the template to use to 142 initialize the interpreter via venv startup hooks. 143* (runfiles) (Bazel 7.4+) Added support for spaces and newlines in runfiles paths 144 145{#v1-0-0-removed} 146### Removed 147* (pypi): Remove `pypi_install_dependencies` macro that has been included in 148 {bzl:obj}`py_repositories` for a long time. 149* (bzlmod): Remove `DEFAULT_PYTHON_VERSION` from `interpreters.bzl` file. If 150 you need the version, please use it from the `versions.bzl` file instead. 151 152{#v0-40-0} 153## [0.40.0] - 2024-11-17 154 155[0.40.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.40.0 156 157{#v0-40-changed} 158### Changed 159* Nothing changed. 160 161{#v0-40-fixed} 162### Fixed 163* (rules) Don't drop custom import paths if Bazel-builtin PyInfo is removed. 164 ([2414](https://github.com/bazelbuild/rules_python/issues/2414)). 165 166{#v0-40-added} 167### Added 168* Nothing added. 169 170{#v0-40-removed} 171### Removed 172* (publish) Remove deprecated `requirements.txt` for the `twine` dependencies. 173 Please use `requirements_linux.txt` instead. 174* (python_repository) Use bazel's built in `zstd` support and remove attributes 175 for customizing the `zstd` binary to be used for `zstd` archives in the 176 {bzl:obj}`python_repository` repository_rule. This affects the 177 {bzl:obj}`python_register_toolchains` and 178 {bzl:obj}`python_register_multi_toolchains` callers in the `WORKSPACE`. 179 180{#v0-39-0} 181## [0.39.0] - 2024-11-13 182 183[0.39.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.39.0 184 185{#v0-39-0-changed} 186### Changed 187* (deps) bazel_skylib 1.6.1 -> 1.7.1 188* (deps) rules_cc 0.0.9 -> 0.0.14 189* (deps) protobuf 24.4 -> 29.0-rc2 190* (deps) rules_proto 6.0.0-rc1 -> 6.0.2 191* (deps) stardoc 0.6.2 -> 0.7.1 192* For bzlmod, Bazel 7.4 is now the minimum Bazel version. 193* (toolchains) Use the latest indygreg toolchain release [20241016] for Python versions: 194 * 3.9.20 195 * 3.10.15 196 * 3.11.10 197 * 3.12.7 198 * 3.13.0 199* (pypi) The naming scheme for the `bzlmod` spoke repositories have changed as 200 all of the given `requirements.txt` files are now parsed by `default`, to 201 temporarily restore the behavior, you can use 202 {bzl:obj}`pip.parse.extra_hub_aliases`, which will be removed or made noop in 203 the future. 204 205[20241016]: https://github.com/indygreg/python-build-standalone/releases/tag/20241016 206 207{#v0-39-0-fixed} 208### Fixed 209* (precompiling) Skip precompiling (instead of erroring) if the legacy 210 `@bazel_tools//tools/python:autodetecting_toolchain` is being used 211 ([#2364](https://github.com/bazelbuild/rules_python/issues/2364)). 212 213{#v0-39-0-added} 214### Added 215* Bazel 8 is now supported. 216* (toolchain) Support for freethreaded Python toolchains is now available. Use 217 the config flag `//python/config_settings:py_freethreaded` to toggle the 218 selection of the free-threaded toolchains. 219* (toolchain) {obj}`py_runtime.abi_flags` attribute and 220 {obj}`PyRuntimeInfo.abi_flags` field added. 221 222{#v0-39-0-removed} 223### Removed 224* Support for Bazel 6 using bzlmod has been dropped. 225 226{#v0-38-0} 227## [0.38.0] - 2024-11-08 228 229[0.38.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.38.0 230 231{#v0-38-0-changed} 232### Changed 233* (deps) (WORKSPACE only) rules_cc 0.0.13 and protobuf 27.0 is now the default 234 version used; this for Bazel 8+ support (previously version was rules_cc 0.0.9 235 and no protobuf version specified) 236 ([2310](https://github.com/bazelbuild/rules_python/issues/2310)). 237* (publish) The dependencies have been updated to the latest available versions 238 for the `twine` publishing rule. 239* (whl_library) Remove `--no-build-isolation` to allow non-hermetic sdist builds 240 by default. Users wishing to keep this argument and to enforce more hermetic 241 builds can do so by passing the argument in 242 [`pip.parse#extra_pip_args`](https://rules-python.readthedocs.io/en/latest/api/rules_python/python/extensions/pip.html#pip.parse.extra_pip_args) 243* (pip.parse) {attr}`pip.parse.whl_modifications` now normalizes the given whl names 244 and now `pyyaml` and `PyYAML` will both work. 245* (bzlmod) `pip.parse` spoke repository naming will be changed in an upcoming 246 release in places where the users specify different package versions per 247 platform in the same hub repository. The naming of the spoke repos is 248 considered an implementation detail and we advise the users to use the `hub` 249 repository directly and make use of {bzl:obj}`pip.parse.extra_hub_aliases` 250 feature added in this release. 251 252{#v0-38-0-fixed} 253### Fixed 254* (pypi) (Bazel 7.4+) Allow spaces in filenames included in `whl_library`s 255 ([617](https://github.com/bazelbuild/rules_python/issues/617)). 256* (pypi) When {attr}`pip.parse.experimental_index_url` is set, we need to still 257 pass the `extra_pip_args` value when building an `sdist`. 258* (pypi) The patched wheel filenames from now on are using local version specifiers 259 which fixes usage of the said wheels using standard package managers. 260* (bzlmod) The extension evaluation has been adjusted to always generate the 261 same lock file irrespective if `experimental_index_url` is set by any module 262 or not. To opt into this behavior, set 263 `pip.parse.parse_all_requirements_files`, which will become the 264 default in future releases leading up to `1.0.0`. Fixes 265 [#2268](https://github.com/bazelbuild/rules_python/issues/2268). A known 266 issue is that it may break `bazel query` and in these use cases it is 267 advisable to use `cquery` or switch to `download_only = True` 268 269{#v0-38-0-added} 270### Added 271* (publish) The requirements file for the `twine` publishing rules have been 272 updated to have a new convention: `requirements_darwin.txt`, 273 `requirements_linux.txt`, `requirements_windows.txt` for each respective OS 274 and one extra file `requirements_universal.txt` if you prefer a single file. 275 The `requirements.txt` file may be removed in the future. 276* The rules_python version is now reported in `//python/features.bzl#features.version` 277* (pip.parse) {attr}`pip.parse.extra_hub_aliases` can now be used to expose extra 278 targets created by annotations in whl repositories. 279 Fixes [#2187](https://github.com/bazelbuild/rules_python/issues/2187). 280* (bzlmod) `pip.parse` now supports `whl-only` setup using 281 `download_only = True` where users can specify multiple requirements files 282 and use the `pip` backend to do the downloading. This was only available for 283 users setting {bzl:obj}`pip.parse.experimental_index_url`, but now users have 284 more options whilst we continue to work on stabilizing the experimental feature. 285 286{#v0-37-2} 287## [0.37.2] - 2024-10-27 288 289[0.37.2]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.2 290 291{#v0-37-2-fixed} 292### Fixed 293* (bzlmod) Generate `config_setting` values for all available toolchains instead 294 of only the registered toolchains, which restores the previous behaviour that 295 `bzlmod` users would have observed. 296 297{#v0-37-1} 298## [0.37.1] - 2024-10-22 299 300[0.37.1]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.1 301 302{#v0-37-1-fixed} 303### Fixed 304* (rules) Setting `--incompatible_python_disallow_native_rules` no longer 305 causes rules_python rules to fail 306 ([#2326](https://github.com/bazelbuild/rules_python/issues/2326)). 307 308{#v0-37-0} 309## [0.37.0] - 2024-10-18 310 311[0.37.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.0 312 313{#v0-37-0-changed} 314### Changed 315* **BREAKING** `py_library` no longer puts its source files or generated pyc 316 files in runfiles; it's the responsibility of consumers (e.g. binaries) to 317 populate runfiles with the necessary files. Adding source files to runfiles 318 can be temporarily restored by setting {obj}`--add_srcs_to_runfiles=enabled`, 319 but this flag will be removed in a subsequent releases. 320* {obj}`PyInfo.transitive_sources` is now added to runfiles. These files are 321 `.py` files that are required to be added to runfiles by downstream binaries 322 (or equivalent). 323* (toolchains) `py_runtime.implementation_name` now defaults to `cpython` 324 (previously it defaulted to None). 325* (toolchains) The exec tools toolchain is enabled by default. It can be 326 disabled by setting 327 {obj}`--@rules_python//python/config_settings:exec_tools_toolchain=disabled`. 328* (deps) stardoc 0.6.2 added as dependency. 329 330{#v0-37-0-fixed} 331### Fixed 332* (bzlmod) The `python.override(minor_mapping)` now merges the default and the 333 overridden versions ensuring that the resultant `minor_mapping` will always 334 have all of the python versions. 335* (bzlmod) The default value for the {obj}`--python_version` flag will now be 336 always set to the default python toolchain version value. 337* (bzlmod) correctly wire the {attr}`pip.parse.extra_pip_args` all the 338 way to {obj}`whl_library`. What is more we will pass the `extra_pip_args` to 339 {obj}`whl_library` for `sdist` distributions when using 340 {attr}`pip.parse.experimental_index_url`. See 341 [#2239](https://github.com/bazelbuild/rules_python/issues/2239). 342* (whl_filegroup): Provide per default also the `RECORD` file 343* (py_wheel): `RECORD` file entry elements are now quoted if necessary when a 344 wheel is created 345* (whl_library) truncate progress messages from the repo rule to better handle 346 case where a requirement has many `--hash=sha256:...` flags 347* (rules) `compile_pip_requirements` passes `env` to the `X.update` target (and 348 not only to the `X_test` target, a bug introduced in 349 [#1067](https://github.com/bazelbuild/rules_python/pull/1067)). 350* (bzlmod) In hybrid bzlmod with WORKSPACE builds, 351 `python_register_toolchains(register_toolchains=True)` is respected 352 ([#1675](https://github.com/bazelbuild/rules_python/issues/1675)). 353* (precompiling) The {obj}`pyc_collection` attribute now correctly 354 enables (or disables) using pyc files from targets transitively 355* (pip) Skip patching wheels not matching `pip.override`'s `file` 356 ([#2294](https://github.com/bazelbuild/rules_python/pull/2294)). 357* (chore): Add a `rules_shell` dev dependency and moved a `sh_test` target 358 outside of the `//:BUILD.bazel` file. 359 Fixes [#2299](https://github.com/bazelbuild/rules_python/issues/2299). 360 361{#v0-37-0-added} 362### Added 363* (py_wheel) Now supports `compress = (True|False)` to allow disabling 364 compression to speed up development. 365* (toolchains): A public `//python/config_settings:python_version_major_minor` has 366 been exposed for users to be able to match on the `X.Y` version of a Python 367 interpreter. 368* (api) Added {obj}`merge_py_infos()` so user rules can merge and propagate 369 `PyInfo` without losing information. 370* (toolchains) New Python versions available: 3.13.0 using the [20241008] release. 371* (toolchains): Bump default toolchain versions to: 372 * `3.8 -> 3.8.20` 373 * `3.9 -> 3.9.20` 374 * `3.10 -> 3.10.15` 375 * `3.11 -> 3.11.10` 376 * `3.12 -> 3.12.7` 377* (coverage) Add support for python 3.13 and bump `coverage.py` to 7.6.1. 378* (bzlmod) Add support for `download_only` flag to disable usage of `sdists` 379 when {bzl:attr}`pip.parse.experimental_index_url` is set. 380* (api) PyInfo fields: {obj}`PyInfo.transitive_implicit_pyc_files`, 381 {obj}`PyInfo.transitive_implicit_pyc_source_files`. 382 383[20241008]: https://github.com/indygreg/python-build-standalone/releases/tag/20241008 384 385{#v0-37-0-removed} 386### Removed 387* (precompiling) {obj}`--precompile_add_to_runfiles` has been removed. 388* (precompiling) {obj}`--pyc_collection` has been removed. The `pyc_collection` 389 attribute now bases its default on {obj}`--precompile`. 390* (precompiling) The {obj}`precompile=if_generated_source` value has been removed. 391* (precompiling) The {obj}`precompile_source_retention=omit_if_generated_source` value has been removed. 392 393{#v0-36-0} 394## [0.36.0] - 2024-09-24 395 396[0.36.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.36.0 397 398{#v0-36-0-changed} 399### Changed 400* (gazelle): Update error messages when unable to resolve a dependency to be more human-friendly. 401* (flags) The {obj}`--python_version` flag now also returns 402 {obj}`config_common.FeatureFlagInfo`. 403* (toolchain): The toolchain patches now expose the `patch_strip` attribute 404 that one should use when patching toolchains. Please set it if you are 405 patching python interpreter. In the next release the default will be set to 406 `0` which better reflects the defaults used in public `bazel` APIs. 407* (toolchains) When {obj}`py_runtime.interpreter_version_info` isn't specified, 408 the {obj}`--python_version` flag will determine the value. This allows 409 specifying the build-time Python version for the 410 {obj}`runtime_env_toolchains`. 411* (toolchains) {obj}`py_cc_toolchain.libs` and {obj}`PyCcToolchainInfo.libs` is 412 optional. This is to support situations where only the Python headers are 413 available. 414* (bazel) Minimum bazel 7 version that we test against has been bumped to `7.1`. 415 416{#v0-36-0-fixed} 417### Fixed 418* (whl_library): Remove `--no-index` and add `--no-build-isolation` to the 419 `pip install` command when installing a wheel from a local file, which happens 420 when `experimental_index_url` flag is used. 421* (bzlmod) get the path to the host python interpreter in a way that results in 422 platform non-dependent hashes in the lock file when the requirement markers need 423 to be evaluated. 424* (bzlmod) correctly watch sources used for evaluating requirement markers for 425 any changes so that the repository rule or module extensions can be 426 re-evaluated when the said files change. 427* (gazelle): Fix incorrect use of `t.Fatal`/`t.Fatalf` in tests. 428* (toolchain) Omit third-party python packages from coverage reports from 429 stage2 bootstrap template. 430* (bzlmod) Properly handle relative path URLs in parse_simpleapi_html.bzl 431* (gazelle) Correctly resolve deps that have top-level module overlap with a gazelle_python.yaml dep module 432* (rules) Make `RUNFILES_MANIFEST_FILE`-based invocations work when used with 433 {obj}`--bootstrap_impl=script`. This fixes invocations using non-sandboxed 434 test execution with `--enable_runfiles=false --build_runfile_manifests=true`. 435 ([#2186](https://github.com/bazelbuild/rules_python/issues/2186)). 436* (py_wheel) Fix incorrectly generated `Required-Dist` when specifying requirements with markers 437 in extra_requires in py_wheel rule. 438* (rules) Prevent pytest from trying run the generated stage2 439 bootstrap .py file when using {obj}`--bootstrap_impl=script` 440* (toolchain) The {bzl:obj}`gen_python_config_settings` has been fixed to include 441 the flag_values from the platform definitions. 442 443{#v0-36-0-added} 444### Added 445* (bzlmod): Toolchain overrides can now be done using the new 446 {bzl:obj}`python.override`, {bzl:obj}`python.single_version_override` and 447 {bzl:obj}`python.single_version_platform_override` tag classes. 448 See [#2081](https://github.com/bazelbuild/rules_python/issues/2081). 449* (rules) Executables provide {obj}`PyExecutableInfo`, which contains 450 executable-specific information useful for packaging an executable or 451 or deriving a new one from the original. 452* (py_wheel) Removed use of bash to avoid failures on Windows machines which do not 453 have it installed. 454* (docs) Automatically generated documentation for {bzl:obj}`python_register_toolchains` 455 and related symbols. 456* (toolchains) Added {attr}`python_repository.patch_strip` attribute for 457 allowing values that are other than `1`, which has been hard-coded up until 458 now. If you are relying on the undocumented `patches` support in 459 `TOOL_VERSIONS` for registering patched toolchains please consider setting 460 the `patch_strip` explicitly to `1` if you depend on this value - in the 461 future the value may change to default to `0`. 462* (toolchains) Added `//python:none`, a special target for use with 463 {obj}`py_exec_tools_toolchain.exec_interpreter` to treat the value as `None`. 464 465{#v0-36-0-removed} 466### Removed 467* (toolchains): Removed accidentally exposed `http_archive` symbol from 468 `python/repositories.bzl`. 469* (toolchains): An internal _is_python_config_setting_ macro has been removed. 470 471{#v0-35-0} 472## [0.35.0] - 2024-08-15 473 474[0.35.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.35.0 475 476{#v0-35-0-changed} 477### Changed 478* (whl_library) A better log message when the wheel is built from an sdist or 479 when the wheel is downloaded using `download_only` feature to aid debugging. 480* (gazelle): Simplify and make gazelle_python.yaml have only top level package name. 481 It would work well in cases to reduce merge conflicts. 482* (toolchains): Change some old toochain versions to use [20240726] release to 483 include dependency updates `3.8.19`, `3.9.19`, `3.10.14`, `3.11.9` 484* (toolchains): Bump default toolchain versions to: 485 * `3.12 -> 3.12.4` 486* (rules) `PYTHONSAFEPATH` is inherited from the calling environment to allow 487 disabling it (Requires {obj}`--bootstrap_impl=script`) 488 ([#2060](https://github.com/bazelbuild/rules_python/issues/2060)). 489 490{#v0-35-0-fixed} 491### Fixed 492* (rules) `compile_pip_requirements` now sets the `USERPROFILE` env variable on 493 Windows to work around an issue where `setuptools` fails to locate the user's 494 home directory. 495* (rules) correctly handle absolute URLs in parse_simpleapi_html.bzl. 496* (rules) Fixes build targets linking against `@rules_python//python/cc:current_py_cc_libs` 497 in host platform builds on macOS, by editing the `LC_ID_DYLIB` field of the hermetic interpreter's 498 `libpython3.x.dylib` using `install_name_tool`, setting it to its absolute path under Bazel's 499 execroot. 500* (rules) Signals are properly received when using {obj}`--bootstrap_impl=script` 501 (for non-zip builds). 502 ([#2043](https://github.com/bazelbuild/rules_python/issues/2043)) 503* (rules) Fixes Python builds when the `--build_python_zip` is set to `false` on 504 Windows. See [#1840](https://github.com/bazelbuild/rules_python/issues/1840). 505* (rules) Fixes Mac + `--build_python_zip` + {obj}`--bootstrap_impl=script` 506 ([#2030](https://github.com/bazelbuild/rules_python/issues/2030)). 507* (rules) User dependencies come before runtime site-packages when using 508 {obj}`--bootstrap_impl=script`. 509 ([#2064](https://github.com/bazelbuild/rules_python/issues/2064)). 510* (rules) Version-aware rules now return both `@_builtins` and `@rules_python` 511 providers instead of only one. 512 ([#2114](https://github.com/bazelbuild/rules_python/issues/2114)). 513* (pip) Fixed pypi parse_simpleapi_html function for feeds with package metadata 514 containing ">" sign 515* (toolchains) Added missing executable permission to 516 `//python/runtime_env_toolchains` interpreter script so that it is runnable. 517 ([#2085](https://github.com/bazelbuild/rules_python/issues/2085)). 518* (pip) Correctly use the `sdist` downloaded by the bazel downloader when using 519 `experimental_index_url` feature. Fixes 520 [#2091](https://github.com/bazelbuild/rules_python/issues/2090). 521* (gazelle) Make `gazelle_python_manifest.update` manual to avoid unnecessary 522 network behavior. 523* (bzlmod): The conflicting toolchains during `python` extension will no longer 524 cause warnings by default. In order to see the warnings for diagnostic purposes 525 set the env var `RULES_PYTHON_REPO_DEBUG_VERBOSITY` to one of `INFO`, `DEBUG` or `TRACE`. 526 Fixes [#1818](https://github.com/bazelbuild/rules_python/issues/1818). 527* (runfiles) Make runfiles lookups work for the situation of Bazel 7, 528 Python 3.9 (or earlier, where safepath isn't present), and the Rlocation call 529 in the same directory as the main file. 530 Fixes [#1631](https://github.com/bazelbuild/rules_python/issues/1631). 531 532{#v0-35-0-added} 533### Added 534* (rules) `compile_pip_requirements` supports multiple requirements input files as `srcs`. 535* (rules) `PYTHONSAFEPATH` is inherited from the calling environment to allow 536 disabling it (Requires {obj}`--bootstrap_impl=script`) 537 ([#2060](https://github.com/bazelbuild/rules_python/issues/2060)). 538* (gazelle) Added `python_generation_mode_per_package_require_test_entry_point` 539 in order to better accommodate users who use a custom macro, 540 [`pytest-bazel`][pytest_bazel], [rules_python_pytest] or `rules_py` 541 [py_test_main] in order to integrate with `pytest`. Currently the default 542 flag value is set to `true` for backwards compatible behaviour, but in the 543 future the flag will be flipped be `false` by default. 544* (toolchains) New Python versions available: `3.12.4` using the [20240726] release. 545* (pypi) Support env markers in requirements files. Note, that this means that 546 if your requirements files contain env markers, the Python interpreter will 547 need to be run during bzlmod phase to evaluate them. This may incur 548 downloading an interpreter (for hermetic-based builds) or cause non-hermetic 549 behavior (if using a system Python). 550 551[rules_python_pytest]: https://github.com/caseyduquettesc/rules_python_pytest 552[py_test_main]: https://docs.aspect.build/rulesets/aspect_rules_py/docs/rules/#py_pytest_main 553[pytest_bazel]: https://pypi.org/project/pytest-bazel 554[20240726]: https://github.com/indygreg/python-build-standalone/releases/tag/20240726 555 556{#v0-34-0} 557## [0.34.0] - 2024-07-04 558 559[0.34.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.34.0 560 561{#v0-34-0-changed} 562### Changed 563* `protobuf`/`com_google_protobuf` dependency bumped to `v24.4` 564* (bzlmod): optimize the creation of config settings used in pip to 565 reduce the total number of targets in the hub repo. 566* (toolchains) The exec tools toolchain now finds its interpreter by reusing 567 the regular interpreter toolchain. This avoids having to duplicate specifying 568 where the runtime for the exec tools toolchain is. 569* (toolchains) ({obj}`//python:autodetecting_toolchain`) is deprecated. It is 570 replaced by {obj}`//python/runtime_env_toolchains:all`. The old target will be 571 removed in a future release. 572 573{#v0-34-0-fixed} 574### Fixed 575* (bzlmod): When using `experimental_index_url` the `all_requirements`, 576 `all_whl_requirements` and `all_data_requirements` will now only include 577 common packages that are available on all target platforms. This is to ensure 578 that packages that are only present for some platforms are pulled only via 579 the `deps` of the materialized `py_library`. If you would like to include 580 platform specific packages, using a `select` statement with references to the 581 specific package will still work (e.g. 582 ``` 583 my_attr = all_requirements + select( 584 { 585 "@platforms//os:linux": ["@pypi//foo_available_only_on_linux"], 586 "//conditions:default": [], 587 } 588 ) 589 ``` 590* (bzlmod): Targets in `all_requirements` now use the same form as targets returned by the `requirement` macro. 591* (rules) Auto exec groups are enabled. This allows actions run by the rules, 592 such as precompiling, to pick an execution platform separately from what 593 other toolchains support. 594* (providers) {obj}`PyRuntimeInfo` doesn't require passing the 595 `interpreter_version_info` arg. 596* (bzlmod) Correctly pass `isolated`, `quiet` and `timeout` values to `whl_library` 597 and drop the defaults from the lock file. 598* (whl_library) Correctly handle arch-specific dependencies when we encounter a 599 platform specific wheel and use `experimental_target_platforms`. 600 Fixes [#1996](https://github.com/bazelbuild/rules_python/issues/1996). 601* (rules) The first element of the default outputs is now the executable again. 602* (pip) Fixed crash when pypi packages lacked a sha (e.g. yanked packages) 603 604{#v0-34-0-added} 605### Added 606* (toolchains) {obj}`//python/runtime_env_toolchains:all`, which is a drop-in 607 replacement for the "autodetecting" toolchain. 608* (gazelle) Added new `python_label_convention` and `python_label_normalization` directives. These directive 609 allows altering default Gazelle label format to third-party dependencies useful for re-using Gazelle plugin 610 with other rules, including `rules_pycross`. See [#1939](https://github.com/bazelbuild/rules_python/issues/1939). 611 612{#v0-34-0-removed} 613### Removed 614* (pip): Removes the `entrypoint` macro that was replaced by `py_console_script_binary` in 0.26.0. 615 616{#v0-33-2} 617## [0.33.2] - 2024-06-13 618 619[0.33.2]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.2 620 621{#v0-33-2-fixed} 622### Fixed 623* (toolchains) The {obj}`exec_tools_toolchain_type` is disabled by default. 624 To enable it, set {obj}`--//python/config_settings:exec_tools_toolchain=enabled`. 625 This toolchain must be enabled for precompilation to work. This toolchain will 626 be enabled by default in a future release. 627 Fixes [#1967](https://github.com/bazelbuild/rules_python/issues/1967). 628 629{#v0-33-1} 630## [0.33.1] - 2024-06-13 631 632[0.33.1]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.1 633 634{#v0-33-1-fixed} 635### Fixed 636* (py_binary) Fix building of zip file when using `--build_python_zip` 637 argument. Fixes [#1954](https://github.com/bazelbuild/rules_python/issues/1954). 638 639{#v0-33-0} 640## [0.33.0] - 2024-06-12 641 642[0.33.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.0 643 644{#v0-33-0-changed} 645### Changed 646* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip. 647* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and 648 `py_library` now depend on the `//python:exec_tools_toolchain_type` for build 649 tools. 650* (deps): Bumped `bazel_skylib` to 1.6.1. 651* (bzlmod): The `python` and internal `rules_python` extensions have been 652 marked as `reproducible` and will not include any lock file entries from now 653 on. 654* (gazelle): Remove gazelle plugin's python deps and make it hermetic. 655 Introduced a new Go-based helper leveraging tree-sitter for syntax analysis. 656 Implemented the use of `pypi/stdlib-list` for standard library module verification. 657* (pip.parse): Do not ignore yanked packages when using `experimental_index_url`. 658 This is to mimic what `uv` is doing. We will print a warning instead. 659* (pip.parse): Add references to all supported wheels when using `experimental_index_url` 660 to allowing to correctly fetch the wheels for the right platform. See the 661 updated docs on how to use the feature. This is work towards addressing 662 [#735](https://github.com/bazelbuild/rules_python/issues/735) and 663 [#260](https://github.com/bazelbuild/rules_python/issues/260). The spoke 664 repository names when using this flag will have a structure of 665 `{pip_hub_prefix}_{wheel_name}_{py_tag}_{abi_tag}_{platform_tag}_{sha256}`, 666 which is an implementation detail which should not be relied on and is there 667 purely for better debugging experience. 668* (bzlmod) The `pythons_hub//:interpreters.bzl` no longer has platform-specific 669 labels which where left there for compatibility reasons. Move to 670 `python_{version}_host` keys if you would like to have access to a Python 671 interpreter that can be used in a repository rule context. 672 673{#v0-33-0-fixed} 674### Fixed 675* (gazelle) Remove `visibility` from `NonEmptyAttr`. 676 Now empty(have no `deps/main/srcs/imports` attr) `py_library/test/binary` rules will 677 be automatically deleted correctly. For example, if `python_generation_mode` 678 is set to package, when `__init__.py` is deleted, the `py_library` generated 679 for this package before will be deleted automatically. 680* (whl_library): Use _is_python_config_setting_ to correctly handle multi-python 681 version dependency select statements when the `experimental_target_platforms` 682 includes the Python ABI. The default python version case within the select is 683 also now handled correctly, stabilizing the implementation. 684* (gazelle) Fix Gazelle failing on Windows with 685 "panic: runtime error: invalid memory address or nil pointer dereference" 686* (bzlmod) remove `pip.parse(annotations)` attribute as it is unused and has been 687 replaced by whl_modifications. 688* (pip) Correctly select wheels when the python tag includes minor versions. 689 See ([#1930](https://github.com/bazelbuild/rules_python/issues/1930)) 690* (pip.parse): The lock file is now reproducible on any host platform if the 691 `experimental_index_url` is not used by any of the modules in the dependency 692 chain. To make the lock file identical on each `os` and `arch`, please use 693 the `experimental_index_url` feature which will fetch metadata from PyPI or a 694 different private index and write the contents to the lock file. Fixes 695 [#1643](https://github.com/bazelbuild/rules_python/issues/1643). 696* (pip.parse): Install `yanked` packages and print a warning instead of 697 ignoring them. This better matches the behaviour of `uv pip install`. 698* (toolchains): Now matching of the default hermetic toolchain is more robust 699 and explicit and should fix rare edge-cases where the host toolchain 700 autodetection would match a different toolchain than expected. This may yield 701 to toolchain selection failures when the python toolchain is not registered, 702 but is requested via `//python/config_settings:python_version` flag setting. 703* (doc) Fix the `WORKSPACE` requirement vendoring example. Fixes 704 [#1918](https://github.com/bazelbuild/rules_python/issues/1918). 705 706{#v0-33-0-added} 707### Added 708* (rules) Precompiling Python source at build time is available. but is 709 disabled by default, for now. Set 710 `@rules_python//python/config_settings:precompile=enabled` to enable it 711 by default. A subsequent release will enable it by default. See the 712 [Precompiling docs][precompile-docs] and API reference docs for more 713 information on precompiling. Note this requires Bazel 7+ and the Pystar rule 714 implementation enabled. 715 ([#1761](https://github.com/bazelbuild/rules_python/issues/1761)) 716* (rules) Attributes and flags to control precompile behavior: `precompile`, 717 `precompile_optimize_level`, `precompile_source_retention`, 718 `precompile_invalidation_mode`, and `pyc_collection` 719* (toolchains) The target runtime toolchain (`//python:toolchain_type`) has 720 two new optional attributes: `pyc_tag` (tells the pyc filename infix to use) and 721 `implementation_name` (tells the Python implementation name). 722* (toolchains) A toolchain type for build tools has been added: 723 `//python:exec_tools_toolchain_type`. 724* (providers) `PyInfo` has two new attributes: `direct_pyc_files` and 725 `transitive_pyc_files`, which tell the pyc files a target makes available 726 directly and transitively, respectively. 727* `//python:features.bzl` added to allow easy feature-detection in the future. 728* (pip) Allow specifying the requirements by (os, arch) and add extra 729 validations when parsing the inputs. This is a non-breaking change for most 730 users unless they have been passing multiple `requirements_*` files together 731 with `extra_pip_args = ["--platform=manylinux_2_4_x86_64"]`, that was an 732 invalid usage previously but we were not failing the build. From now on this 733 is explicitly disallowed. 734* (toolchains) Added riscv64 platform definition for python toolchains. 735* (gazelle) The `python_visibility` directive now supports the `$python_root$` 736 placeholder, just like the `python_default_visibility` directive does. 737* (rules) A new bootstrap implementation that doesn't require a system Python 738 is available. It can be enabled by setting 739 {obj}`--@rules_python//python/config_settings:bootstrap_impl=script`. It 740 will become the default in a subsequent release. 741 ([#691](https://github.com/bazelbuild/rules_python/issues/691)) 742* (providers) `PyRuntimeInfo` has two new attributes: 743 {obj}`PyRuntimeInfo.stage2_bootstrap_template` and 744 {obj}`PyRuntimeInfo.zip_main_template`. 745* (toolchains) A replacement for the Bazel-builtn autodetecting toolchain is 746 available. The `//python:autodetecting_toolchain` alias now uses it. 747* (pip): Support fetching and using the wheels for other platforms. This 748 supports customizing whether the linux wheels are pulled for `musl` or 749 `glibc`, whether `universal2` or arch-specific MacOS wheels are preferred and 750 it also allows to select a particular `libc` version. All of this is done via 751 the `string_flags` in `@rules_python//python/config_settings`. If there are 752 no wheels that are supported for the target platform, `rules_python` will 753 fallback onto building the `sdist` from source. This behaviour can be 754 disabled if desired using one of the available string flags as well. 755* (whl_filegroup) Added a new `whl_filegroup` rule to extract files from a wheel file. 756 This is useful to extract headers for use in a `cc_library`. 757 758[precompile-docs]: /precompiling 759 760{#v0-32-2} 761## [0.32.2] - 2024-05-14 762 763[0.32.2]: https://github.com/bazelbuild/rules_python/releases/tag/0.32.2 764 765{#v0-32-2-fixed} 766### Fixed 767 768* 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]. 769 770[indygreg-231]: https://github.com/indygreg/python-build-standalone/issues/231 771[rules_python_1800]: https://github.com/bazelbuild/rules_python/issues/1800 772 773{#v0-32-0} 774## [0.32.0] - 2024-05-12 775 776[0.32.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.32.0 777 778{#v0-32-0-changed} 779### Changed 780 781* (bzlmod): The `MODULE.bazel.lock` `whl_library` rule attributes are now 782 sorted in the attributes section. We are also removing values that are not 783 default in order to reduce the size of the lock file. 784* (coverage) Bump `coverage.py` to [7.4.3](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst#version-743--2024-02-23). 785* (deps): Bumped `bazel_features` to 1.9.1 to detect optional support 786 non-blocking downloads. 787* (deps): Updated `pip_tools` to >= 7.4.0 788* (toolchains): Change some old toolchain versions to use [20240224] release to 789 include security fixes `3.8.18`, `3.9.18` and `3.10.13` 790* (toolchains): Bump default toolchain versions to: 791 * `3.8 -> 3.8.19` 792 * `3.9 -> 3.9.19` 793 * `3.10 -> 3.10.14` 794 * `3.11 -> 3.11.9` 795 * `3.12 -> 3.12.3` 796 797### Fixed 798 799* (whl_library): Fix the experimental_target_platforms overriding for platform 800 specific wheels when the wheels are for any python interpreter version. Fixes 801 [#1810](https://github.com/bazelbuild/rules_python/issues/1810). 802* (whl_library): Stop generating duplicate dependencies when encountering 803 duplicates in the METADATA. Fixes 804 [#1873](https://github.com/bazelbuild/rules_python/issues/1873). 805* (gazelle) In `project` or `package` generation modes, do not generate `py_test` 806 rules when there are no test files and do not set `main = "__test__.py"` when 807 that file doesn't exist. 808* (whl_library) The group redirection is only added when the package is part of 809 the group potentially fixing aspects that want to traverse a `py_library` graph. 810 Fixes [#1760](https://github.com/bazelbuild/rules_python/issues/1760). 811* (bzlmod) Setting a particular micro version for the interpreter and the 812 `pip.parse` extension is now possible, see the 813 `examples/pip_parse/MODULE.bazel` for how to do it. 814 See [#1371](https://github.com/bazelbuild/rules_python/issues/1371). 815* (refactor) The pre-commit developer workflow should now pass `isort` and `black` 816 checks (see [#1674](https://github.com/bazelbuild/rules_python/issues/1674)). 817 818### Added 819 820* (toolchains) Added armv7 platform definition for python toolchains. 821* (toolchains) New Python versions available: `3.11.8`, `3.12.2` using the [20240224] release. 822* (toolchains) New Python versions available: `3.8.19`, `3.9.19`, `3.10.14`, `3.11.9`, `3.12.3` using 823 the [20240415] release. 824* (gazelle) Added a new `python_visibility` directive to control visibility 825 of generated targets by appending additional visibility labels. 826* (gazelle) Added a new `python_default_visibility` directive to control the 827 _default_ visibility of generated targets. See the [docs][python_default_visibility] 828 for details. 829* (gazelle) Added a new `python_test_file_pattern` directive. This directive tells 830 gazelle which python files should be mapped to the `py_test` rule. See the 831 [original issue][test_file_pattern_issue] and the [docs][test_file_pattern_docs] 832 for details. 833* (wheel) Add support for `data_files` attributes in py_wheel rule 834 ([#1777](https://github.com/bazelbuild/rules_python/issues/1777)) 835* (py_wheel) `bzlmod` installations now provide a `twine` setup for the default 836 Python toolchain in `rules_python` for version 3.11. 837* (bzlmod) New `experimental_index_url`, `experimental_extra_index_urls` and 838 `experimental_index_url_overrides` to `pip.parse` for using the bazel 839 downloader. If you see any issues, report in 840 [#1357](https://github.com/bazelbuild/rules_python/issues/1357). The URLs for 841 the whl and sdist files will be written to the lock file. Controlling whether 842 the downloading of metadata is done in parallel can be done using 843 `parallel_download` attribute. 844* (gazelle) Add a new annotation `include_dep`. Also add documentation for 845 annotations to `gazelle/README.md`. 846* (deps): `rules_python` depends now on `rules_cc` 0.0.9 847* (pip_parse): A new flag `use_hub_alias_dependencies` has been added that is going 848 to become default in the next release. This makes use of `dep_template` flag 849 in the `whl_library` rule. This also affects the 850 `experimental_requirement_cycles` feature where the dependencies that are in 851 a group would be only accessible via the hub repo aliases. If you still 852 depend on legacy labels instead of the hub repo aliases and you use the 853 `experimental_requirement_cycles`, now is a good time to migrate. 854 855[python_default_visibility]: gazelle/README.md#directive-python_default_visibility 856[test_file_pattern_issue]: https://github.com/bazelbuild/rules_python/issues/1816 857[test_file_pattern_docs]: gazelle/README.md#directive-python_test_file_pattern 858[20240224]: https://github.com/indygreg/python-build-standalone/releases/tag/20240224. 859[20240415]: https://github.com/indygreg/python-build-standalone/releases/tag/20240415. 860 861 862## [0.31.0] - 2024-02-12 863 864[0.31.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.31.0 865 866### Changed 867 868* For Bazel 7, the core rules and providers are now implemented in rules_python 869 directly and the rules bundled with Bazel are not used. Bazel 6 and earlier 870 continue to use the Bazel builtin symbols. Of particular note, this means, 871 under Bazel 7, the builtin global symbol `PyInfo` is **not** the same as what 872 is loaded from rules_python. The same is true of `PyRuntimeInfo`. 873 874## [0.30.0] - 2024-02-12 875 876[0.30.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.30.0 877 878### Changed 879 880* (toolchains) Windows hosts always ignore pyc files in the downloaded runtimes. 881 This fixes issues due to pyc files being created at runtime and affecting the 882 definition of what files were considered part of the runtime. 883 884* (pip_parse) Added the `envsubst` parameter, which enables environment variable 885 substitutions in the `extra_pip_args` attribute. 886 887* (pip_repository) Added the `envsubst` parameter, which enables environment 888 variable substitutions in the `extra_pip_args` attribute. 889 890### Fixed 891 892* (bzlmod) pip.parse now does not fail with an empty `requirements.txt`. 893 894* (py_wheel) Wheels generated by `py_wheel` now preserve executable bits when 895 being extracted by `installer` and/or `pip`. 896 897* (coverage) During the running of lcov, the stdout/stderr was causing test 898 failures. By default, suppress output when generating lcov. This can be 899 overridden by setting 'VERBOSE_COVERAGE'. This change only affect bazel 900 7.x.x and above. 901 902* (toolchain) Changed the `host_toolchain` to symlink all files to support 903 Windows host environments without symlink support. 904 905* (PyRuntimeInfo) Switch back to builtin PyRuntimeInfo for Bazel 6.4 and when 906 pystar is disabled. This fixes an error about `target ... does not have ... 907 PyRuntimeInfo`. 908 ([#1732](https://github.com/bazelbuild/rules_python/issues/1732)) 909 910### Added 911 912* (py_wheel) Added `requires_file` and `extra_requires_files` attributes. 913 914* (whl_library) *experimental_target_platforms* now supports specifying the 915 Python version explicitly and the output `BUILD.bazel` file will be correct 916 irrespective of the python interpreter that is generating the file and 917 extracting the `whl` distribution. Multiple python target version can be 918 specified and the code generation will generate version specific dependency 919 closures but that is not yet ready to be used and may break the build if 920 the default python version is not selected using 921 `common --@rules_python//python/config_settings:python_version=X.Y.Z`. 922 923* New Python versions available: `3.11.7`, `3.12.1` using 924 https://github.com/indygreg/python-build-standalone/releases/tag/20240107. 925 926* (toolchain) Allow setting `x.y` as the `python_version` parameter in 927 the version-aware `py_binary` and `py_test` rules. This allows users to 928 use the same rule import for testing with specific Python versions and 929 rely on toolchain configuration and how the latest version takes precedence 930 if e.g. `3.8` is selected. That also simplifies `.bazelrc` for any users 931 that set the default `python_version` string flag in that way. 932 933* (toolchain) The runtime's shared libraries (libpython.so et al) can be 934 accessed using `@rules_python//python/cc:current_py_cc_libs`. This uses 935 toolchain resolution, so the files are from the same runtime used to run a 936 target. If you were previously using e.g. `@python_3_11//:libpython`, then 937 switch to `:current_py_cc_libs` for looser coupling to the underlying runtime 938 repo implementation. 939 940* (repo rules) The environment variable `RULES_PYTHON_REPO_DEBUG=1` can be 941 set to make repository rules log detailed information about what they're 942 up to. 943 944* (coverage) Add support for python 3.12 and bump `coverage.py` to 945 7.4.1. 946 947 948## [0.29.0] - 2024-01-22 949 950[0.29.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.29.0 951 952### Changed 953 954* **BREAKING** The deprecated `incompatible_generate_aliases` feature flags 955 from `pip_parse` and `gazelle` got removed. They had been flipped to `True` 956 in 0.27.0 release. 957* **BREAKING** (wheel) The `incompatible_normalize_name` and 958 `incompatible_normalize_version` flags have been removed. They had been 959 flipped to `True` in 0.27.0 release. 960* (bzlmod) The pip hub repository now uses the newly introduced config settings 961 using the `X.Y` python version notation. This improves cross module 962 interoperability and allows to share wheels built by interpreters using 963 different patch versions. 964 965### Fixed 966 967* (bzlmod pip.parse) Use a platform-independent reference to the interpreter 968 pip uses. This reduces (but doesn't eliminate) the amount of 969 platform-specific content in `MODULE.bazel.lock` files; Follow 970 [#1643](https://github.com/bazelbuild/rules_python/issues/1643) for removing 971 platform-specific content in `MODULE.bazel.lock` files. 972 973* (wheel) The stamp variables inside the distribution name are no longer 974 lower-cased when normalizing under PEP440 conventions. 975 976### Added 977 978* (toolchains) `python_register_toolchains` now also generates a repository 979 that is suffixed with `_host`, that has a single label `:python` that is a 980 symlink to the python interpreter for the host platform. The intended use is 981 mainly in `repository_rule`, which are always run using `host` platform 982 Python. This means that `WORKSPACE` users can now copy the `requirements.bzl` 983 file for vendoring as seen in the updated `pip_parse_vendored` example. 984 985* (runfiles) `rules_python.python.runfiles.Runfiles` now has a static `Create` 986 method to make imports more ergonomic. Users should only need to import the 987 `Runfiles` object to locate runfiles. 988 989* (toolchains) `PyRuntimeInfo` now includes a `interpreter_version_info` field 990 that contains the static version information for the given interpreter. 991 This can be set via `py_runtime` when registering an interpreter toolchain, 992 and will done automatically for the builtin interpreter versions registered via 993 `python_register_toolchains`. 994 Note that this only available on the Starlark implementation of the provider. 995 996* (config_settings) Added `//python/config_settings:is_python_X.Y` config 997 settings to match on minor Python version. These settings match any `X.Y` 998 version instead of just an exact `X.Y.Z` version. 999 1000## [0.28.0] - 2024-01-07 1001 1002[0.28.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.28.0 1003 1004### Changed 1005 1006* **BREAKING** (pip_install) the deprecated `pip_install` macro and related 1007 items have been removed. 1008 1009* **BREAKING** Support for Bazel 5 has been officially dropped. This release 1010 was only partially tested with Bazel 5 and may or may not work with Bazel 5. 1011 Subequent versions will no longer be tested under Bazel 5. 1012 1013* (runfiles) `rules_python.python.runfiles` now directly implements type hints 1014 and drops support for python2 as a result. 1015 1016* (toolchains) `py_runtime`, `py_runtime_pair`, and `PyRuntimeInfo` now use the 1017 rules_python Starlark implementation, not the one built into Bazel. NOTE: This 1018 only applies to Bazel 6+; Bazel 5 still uses the builtin implementation. 1019 1020* (pip_parse) The parameter `experimental_requirement_cycles` may be provided a 1021 map of names to lists of requirements which form a dependency 1022 cycle. `pip_parse` will break the cycle for you transparently. This behavior 1023 is also available under bzlmod as 1024 `pip.parse(experimental_requirement_cycles={})`. 1025 1026* (toolchains) `py_runtime` can now take an executable target. Note: runfiles 1027 from the target are not supported yet. 1028 ([#1612](https://github.com/bazelbuild/rules_python/issues/1612)) 1029 1030* (gazelle) When `python_generation_mode` is set to `file`, create one `py_binary` 1031 target for each file with `if __name__ == "__main__"` instead of just one 1032 `py_binary` for the whole module. 1033 1034* (gazelle) the Gazelle manifest integrity field is now optional. If the 1035 `requirements` argument to `gazelle_python_manifest` is unset, no integrity 1036 field will be generated. 1037 1038### Fixed 1039 1040* (gazelle) The gazelle plugin helper was not working with Python toolchains 3.11 1041 and above due to a bug in the helper components not being on PYTHONPATH. 1042 1043* (pip_parse) The repositories created by `whl_library` can now parse the `whl` 1044 METADATA and generate dependency closures irrespective of the host platform 1045 the generation is executed on. This can be turned on by supplying 1046 `experimental_target_platforms = ["all"]` to the `pip_parse` or the `bzlmod` 1047 equivalent. This may help in cases where fetching wheels for a different 1048 platform using `download_only = True` feature. 1049* (bzlmod pip.parse) The `pip.parse(python_interpreter)` arg now works for 1050 specifying a local system interpreter. 1051* (bzlmod pip.parse) Requirements files with duplicate entries for the same 1052 package (e.g. one for the package, one for an extra) now work. 1053* (bzlmod python.toolchain) Submodules can now (re)register the Python version 1054 that rules_python has set as the default. 1055 ([#1638](https://github.com/bazelbuild/rules_python/issues/1638)) 1056* (whl_library) Actually use the provided patches to patch the whl_library. 1057 On Windows the patching may result in files with CRLF line endings, as a result 1058 the RECORD file consistency requirement is lifted and now a warning is emitted 1059 instead with a location to the patch that could be used to silence the warning. 1060 Copy the patch to your workspace and add it to the list if patches for the wheel 1061 file if you decide to do so. 1062* (coverage): coverage reports are now created when the version-aware 1063 rules are used. 1064 ([#1600](https://github.com/bazelbuild/rules_python/issues/1600)) 1065* (toolchains) Workspace builds register the py cc toolchain (bzlmod already 1066 was). This makes e.g. `//python/cc:current_py_cc_headers` Just Work. 1067 ([#1669](https://github.com/bazelbuild/rules_python/issues/1669)) 1068* (bzlmod python.toolchain) The value of `ignore_root_user_error` is now decided 1069 by the root module only. 1070 ([#1658](https://github.com/bazelbuild/rules_python/issues/1658)) 1071 1072### Added 1073 1074* (docs) bzlmod extensions are now documented on rules-python.readthedocs.io 1075* (docs) Support and backwards compatibility policies have been documented. 1076 See https://rules-python.readthedocs.io/en/latest/support.html 1077* (gazelle) `file` generation mode can now also add `__init__.py` to the srcs 1078 attribute for every target in the package. This is enabled through a separate 1079 directive `python_generation_mode_per_file_include_init`. 1080 1081## [0.27.0] - 2023-11-16 1082 1083[0.27.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.27.0 1084 1085### Changed 1086 1087* Make `//python/pip_install:pip_repository_bzl` `bzl_library` target internal 1088 as all of the publicly available symbols (etc. `package_annotation`) are 1089 re-exported via `//python:pip_bzl` `bzl_library`. 1090 1091* (gazelle) Gazelle Python extension no longer has runtime dependencies. Using 1092 `GAZELLE_PYTHON_RUNTIME_DEPS` from `@rules_python_gazelle_plugin//:def.bzl` is 1093 no longer necessary. 1094 1095* (pip_parse) The installation of `pip_parse` repository rule toolchain 1096 dependencies is now done as part of `py_repositories` call. 1097 1098* (pip_parse) The generated `requirements.bzl` file now has an additional symbol 1099 `all_whl_requirements_by_package` which provides a map from the normalized 1100 PyPI package name to the target that provides the built wheel file. Use 1101 `pip_utils.normalize_name` function from `@rules_python//python:pip.bzl` to 1102 convert a PyPI package name to a key in the `all_whl_requirements_by_package` 1103 map. 1104 1105* (pip_parse) The flag `incompatible_generate_aliases` has been flipped to 1106 `True` by default on `non-bzlmod` setups allowing users to use the same label 1107 strings during the transition period. For example, instead of 1108 `@pypi_foo//:pkg`, you can now use `@pypi//foo` or `@pypi//foo:pkg`. Other 1109 labels that are present in the `foo` package are `dist_info`, `whl` and 1110 `data`. Note, that the `@pypi_foo//:pkg` labels are still present for 1111 backwards compatibility. 1112 1113* (gazelle) The flag `use_pip_repository_aliases` is now set to `True` by 1114 default, which will cause `gazelle` to change third-party dependency labels 1115 from `@pip_foo//:pkg` to `@pip//foo` by default. 1116 1117* The `compile_pip_requirements` now defaults to `pyproject.toml` if the `src` 1118 or `requirements_in` attributes are unspecified, matching the upstream 1119 `pip-compile` behaviour more closely. 1120 1121* (gazelle) Use relative paths if possible for dependencies added through 1122 the use of the `resolve` directive. 1123 1124* (gazelle) When using `python_generation_mode file`, one `py_test` target is 1125 made per test file even if a target named `__test__` or a file named 1126 `__test__.py` exists in the same package. Previously in these cases there 1127 would only be one test target made. 1128 1129Breaking changes: 1130 1131* (pip) `pip_install` repository rule in this release has been disabled and 1132 will fail by default. The API symbol is going to be removed in the next 1133 version, please migrate to `pip_parse` as a replacement. The `pip_parse` 1134 rule no longer supports `requirements` attribute, please use 1135 `requirements_lock` instead. 1136 1137* (py_wheel) switch `incompatible_normalize_name` and 1138 `incompatible_normalize_version` to `True` by default to enforce `PEP440` 1139 for wheel names built by `rules_python`. 1140 1141* (tools/wheelmaker.py) drop support for Python 2 as only Python 3 is tested. 1142 1143### Fixed 1144 1145* Skip aliases for unloaded toolchains. Some Python versions that don't have full 1146 platform support, and referencing their undefined repositories can break operations 1147 like `bazel query rdeps(...)`. 1148 1149* Python code generated from `proto_library` with `strip_import_prefix` can be imported now. 1150 1151* (py_wheel) Produce deterministic wheel files and make `RECORD` file entries 1152 follow the order of files written to the `.whl` archive. 1153 1154* (gazelle) Generate a single `py_test` target when `gazelle:python_generation_mode project` 1155 is used. 1156 1157* (gazelle) Move waiting for the Python interpreter process to exit to the shutdown hook 1158 to make the usage of the `exec.Command` more idiomatic. 1159 1160* (toolchains) Keep tcl subdirectory in Windows build of hermetic interpreter. 1161 1162* (bzlmod) sub-modules now don't have the `//conditions:default` clause in the 1163 hub repos created by `pip.parse`. This should fix confusing error messages 1164 in case there is a misconfiguration of toolchains or a bug in `rules_python`. 1165 1166### Added 1167 1168* (bzlmod) Added `.whl` patching support via `patches` and `patch_strip` 1169 arguments to the new `pip.override` tag class. 1170 1171* (pip) Support for using [PEP621](https://peps.python.org/pep-0621/) compliant 1172 `pyproject.toml` for creating a resolved `requirements.txt` file. 1173 1174* (utils) Added a `pip_utils` struct with a `normalize_name` function to allow users 1175 to find out how `rules_python` would normalize a PyPI distribution name. 1176 1177## [0.26.0] - 2023-10-06 1178 1179### Changed 1180 1181* Python version patch level bumps: 1182 * 3.8.15 -> 3.8.18 1183 * 3.9.17 -> 3.9.18 1184 * 3.10.12 -> 3.10.13 1185 * 3.11.4 -> 3.11.6 1186 1187* (deps) Upgrade rules_go 0.39.1 -> 0.41.0; this is so gazelle integration works with upcoming Bazel versions 1188 1189* (multi-version) The `distribs` attribute is no longer propagated. This 1190 attribute has been long deprecated by Bazel and shouldn't be used. 1191 1192* Calling `//python:repositories.bzl#py_repositories()` is required. It has 1193 always been documented as necessary, but it was possible to omit it in certain 1194 cases. An error about `@rules_python_internal` means the `py_repositories()` 1195 call is missing in `WORKSPACE`. 1196 1197* (bzlmod) The `pip.parse` extension will generate os/arch specific lock 1198 file entries on `bazel>=6.4`. 1199 1200 1201### Added 1202 1203* (bzlmod, entry_point) Added {obj}`py_console_script_binary`, which 1204 allows adding custom dependencies to a package's entry points and customizing 1205 the `py_binary` rule used to build it. 1206 1207* New Python versions available: `3.8.17`, `3.11.5` using 1208 https://github.com/indygreg/python-build-standalone/releases/tag/20230826. 1209 1210* (gazelle) New `# gazelle:python_generation_mode file` directive to support 1211 generating one `py_library` per file. 1212 1213* (python_repository) Support `netrc` and `auth_patterns` attributes to enable 1214 authentication against private HTTP hosts serving Python toolchain binaries. 1215 1216* `//python:packaging_bzl` added, a `bzl_library` for the Starlark 1217 files `//python:packaging.bzl` requires. 1218* (py_wheel) Added the `incompatible_normalize_name` feature flag to 1219 normalize the package distribution name according to latest Python 1220 packaging standards. Defaults to `False` for the time being. 1221* (py_wheel) Added the `incompatible_normalize_version` feature flag 1222 to normalize the package version according to PEP440 standard. This 1223 also adds support for local version specifiers (versions with a `+` 1224 in them), in accordance with PEP440. Defaults to `False` for the 1225 time being. 1226 1227* New Python versions available: `3.8.18`, `3.9.18`, `3.10.13`, `3.11.6`, `3.12.0` using 1228 https://github.com/indygreg/python-build-standalone/releases/tag/20231002. 1229 `3.12.0` support is considered beta and may have issues. 1230 1231### Removed 1232 1233* (bzlmod) The `entry_point` macro is no longer supported and has been removed 1234 in favour of the `py_console_script_binary` macro for `bzlmod` users. 1235 1236* (bzlmod) The `pip.parse` no longer generates `{hub_name}_{py_version}` hub repos 1237 as the `entry_point` macro has been superseded by `py_console_script_binary`. 1238 1239* (bzlmod) The `pip.parse` no longer generates `{hub_name}_{distribution}` hub repos. 1240 1241### Fixed 1242 1243* (whl_library) No longer restarts repository rule when fetching external 1244 dependencies improving initial build times involving external dependency 1245 fetching. 1246 1247* (gazelle) Improve runfiles lookup hermeticity. 1248 1249[0.26.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.26.0 1250 1251## [0.25.0] - 2023-08-22 1252 1253### Changed 1254 1255* Python version patch level bumps: 1256 * 3.9.16 -> 3.9.17 1257 * 3.10.9 -> 3.10.12 1258 * 3.11.1 -> 3.11.4 1259* (bzlmod) `pip.parse` can no longer automatically use the default 1260 Python version; this was an unreliable and unsafe behavior. The 1261 `python_version` arg must always be explicitly specified. 1262 1263### Fixed 1264 1265* (docs) Update docs to use correct bzlmod APIs and clarify how and when to use 1266 various APIs. 1267* (multi-version) The `main` arg is now correctly computed and usually optional. 1268* (bzlmod) `pip.parse` no longer requires a call for whatever the configured 1269 default Python version is. 1270 1271### Added 1272 1273* Created a changelog. 1274* (gazelle) Stop generating unnecessary imports. 1275* (toolchains) s390x supported for Python 3.9.17, 3.10.12, and 3.11.4. 1276 1277[0.25.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.25.0 1278 1279## [0.24.0] - 2023-07-11 1280 1281### Changed 1282 1283* **BREAKING** (gazelle) Gazelle 0.30.0 or higher is required 1284* (bzlmod) `@python_aliases` renamed to `@python_versions 1285* (bzlmod) `pip.parse` arg `name` renamed to `hub_name` 1286* (bzlmod) `pip.parse` arg `incompatible_generate_aliases` removed and always 1287 true. 1288 1289### Fixed 1290 1291* (bzlmod) Fixing Windows Python Interpreter symlink issues 1292* (py_wheel) Allow twine tags and args 1293* (toolchain, bzlmod) Restrict coverage tool visibility under bzlmod 1294* (pip) Ignore temporary pyc.NNN files in wheels 1295* (pip) Add format() calls to glob_exclude templates 1296* plugin_output in py_proto_library rule 1297 1298### Added 1299 1300* Using Gazelle's lifecycle manager to manage external processes 1301* (bzlmod) `pip.parse` can be called multiple times with different Python 1302 versions 1303* (bzlmod) Allow bzlmod `pip.parse` to reference the default python toolchain and interpreter 1304* (bzlmod) Implementing wheel annotations via `whl_mods` 1305* (gazelle) support multiple requirements files in manifest generation 1306* (py_wheel) Support for specifying `Description-Content-Type` and `Summary` in METADATA 1307* (py_wheel) Support for specifying `Project-URL` 1308* (compile_pip_requirements) Added `generate_hashes` arg (default True) to 1309 control generating hashes 1310* (pip) Create all_data_requirements alias 1311* Expose Python C headers through the toolchain. 1312 1313[0.24.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.24.0 1314