From 2687664f0e3262d04e6f91bdd93f07a80a96bbdc Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Thu, 3 Jul 2025 18:02:17 -0700 Subject: [PATCH 1/4] fix(local-toolchains): don't watch non-existent include directory (#3048) Apparently, Macs can mis-report their include directory. Since includes are only needed if C extensions are built, skip watching the directory if it doesn't exist. Work around for https://github.com/bazel-contrib/rules_python/issues/3043 --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com> --- CHANGELOG.md | 130 ++++++++++++++++++++++++++ python/private/local_runtime_repo.bzl | 10 +- 2 files changed, 139 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e839d3103..0a297989f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,136 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> +{#v0-0-0} +## Unreleased + +[0.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.0.0 + +{#v0-0-0-changed} +### Changed +* (gazelle) For package mode, resolve dependencies when imports are relative + to the package path. This is enabled via the + `# gazelle:experimental_allow_relative_imports` true directive ({gh-issue}`2203`). +* (gazelle) Types for exposed members of `python.ParserOutput` are now all public. +* (gazelle) Removed the requirement for `__init__.py`, `__main__.py`, or `__test__.py` files to be + present in a directory to generate a `BUILD.bazel` file. +* (toolchain) Updated the following toolchains to build 20250612 to patch CVE-2025-47273: + * 3.9.23 + * 3.10.18 + * 3.11.13 + * 3.12.11 + * 3.14.0b2 +* (toolchain) Python 3.13 now references 3.13.5 + +{#v0-0-0-fixed} +### Fixed +* (pypi) Fixes an issue where builds using a `bazel vendor` vendor directory + would fail if the constraints file contained environment markers. Fixes + [#2996](https://github.com/bazel-contrib/rules_python/issues/2996). +* (pypi) Wheels with BUILD.bazel (or other special Bazel files) no longer + result in missing files at runtime + ([#2782](https://github.com/bazel-contrib/rules_python/issues/2782)). +* (runfiles) The pypi runfiles package now includes `py.typed` to indicate it + supports type checking + ([#2503](https://github.com/bazel-contrib/rules_python/issues/2503)). +* (toolchains) `local_runtime_repo` now checks if the include directory exists + before attempting to watch it, fixing issues on macOS with system Python + ({gh-issue}`3043`). + +{#v0-0-0-added} +### Added +* (pypi) To configure the environment for `requirements.txt` evaluation, use the newly added + developer preview of the `pip.default` tag class. Only `rules_python` and root modules can use + this feature. You can also configure custom `config_settings` using `pip.default`. +* (gazelle) New directive `gazelle:python_generate_pyi_deps`; when `true`, + dependencies added to satisfy type-only imports (`if TYPE_CHECKING`) and type + stub packages are added to `pyi_deps` instead of `deps`. + +{#v0-0-0-removed} +### Removed +* Nothing removed. + +{#1-5-0} +## [1.5.0] - 2025-06-11 + +[1.5.0]: https://github.com/bazel-contrib/rules_python/releases/tag/1.5.0 + +{#1-5-0-changed} +### Changed + +* (toolchain) Bundled toolchain version updates: + * 3.9 now references 3.9.23 + * 3.10 now references 3.10.18 + * 3.11 now references 3.11.13 + * 3.12 now references 3.12.11 + * 3.13 now references 3.13.4 +* (rules) On Windows, {obj}`--bootstrap_impl=system_python` is forced. This + allows setting `--bootstrap_impl=script` in bazelrc for mixed-platform + environments. +* (rules) {obj}`compile_pip_requirements` now generates a `.test` target. The + `_test` target is deprecated and will be removed in the next major release. + ([#2794](https://github.com/bazel-contrib/rules_python/issues/2794) +* (py_wheel) py_wheel always creates zip64-capable wheel zips +* (providers) (experimental) {obj}`PyInfo.venv_symlinks` replaces + `PyInfo.site_packages_symlinks` +* (deps) Updated setuptools to 78.1.1 to patch CVE-2025-47273. This effectively makes + Python 3.9 the minimum supported version for using `pip_parse`. + +{#1-5-0-fixed} +### Fixed + +* (rules) PyInfo provider is now advertised by py_test, py_binary, and py_library; + this allows aspects using required_providers to function correctly. + ([#2506](https://github.com/bazel-contrib/rules_python/issues/2506)). +* Fixes when using {obj}`--bootstrap_impl=script`: + * `compile_pip_requirements` now works with it + * The `sys._base_executable` value will reflect the underlying interpreter, + not venv interpreter. + * The {obj}`//python/runtime_env_toolchains:all` toolchain now works with it. +* (rules) Better handle flakey platform.win32_ver() calls by calling them + multiple times. +* (tools/wheelmaker.py) Extras are now preserved in Requires-Dist metadata when using requires_file + to specify the requirements. +* (pypi) Use bazel downloader for direct URL references and correctly detect the filenames from + various URL formats - URL encoded version strings get correctly resolved, sha256 value can be + also retrieved from the URL as opposed to only the `--hash` parameter. Fixes + [#2363](https://github.com/bazel-contrib/rules_python/issues/2363). +* (pypi) `whl_library` now infers file names from its `urls` attribute correctly. +* (pypi) When running under `bazel test`, be sure that temporary `requirements` file + remains writable. +* (py_test, py_binary) Allow external files to be used for main +* (pypi) Correctly aggregate the sources when the hashes specified in the lockfile differ + by platform even though the same version is used. Fixes [#2648](https://github.com/bazel-contrib/rules_python/issues/2648). +* (pypi) `compile_pip_requirements` test rule works behind the proxy +* (toolchains) The hermetic toolchains now correctly statically advertise the + `releaselevel` and `serial` for pre-release hermetic toolchains ({gh-issue}`2837`). + +{#1-5-0-added} +### Added +* Repo utilities `execute_unchecked`, `execute_checked`, and `execute_checked_stdout` now + support `log_stdout` and `log_stderr` keyword arg booleans. When these are `True` + (the default), the subprocess's stdout/stderr will be logged. +* (toolchains) Local toolchains can be activated with custom flags. See + [Conditionally using local toolchains] docs for how to configure. +* (pypi) Starlark-based evaluation of environment markers (requirements.txt conditionals) + available (not enabled by default) for improved multi-platform build support. + Set the `RULES_PYTHON_ENABLE_PIPSTAR=1` environment variable to enable it. +* (utils) Add a way to run a REPL for any `rules_python` target that returns + a `PyInfo` provider. +* (uv) Handle `.netrc` and `auth_patterns` auth when downloading `uv`. Work towards + [#1975](https://github.com/bazel-contrib/rules_python/issues/1975). +* (toolchains) Arbitrary python-build-standalone runtimes can be registered + and activated with custom flags. See the [Registering custom runtimes] + docs and {obj}`single_version_platform_override()` API docs for more + information. +* (rules) Added support for a using constraints files with `compile_pip_requirements`. + Useful when an intermediate dependency needs to be upgraded to pull in + security patches. +* (toolchains): 3.14.0b2 has been added as a preview. + +{#1-5-0-removed} +### Removed +* Nothing removed. {#1-4-1} ## [1.4.1] - 2025-05-08 diff --git a/python/private/local_runtime_repo.bzl b/python/private/local_runtime_repo.bzl index fb1a8e29ac..6f1e20aa4b 100644 --- a/python/private/local_runtime_repo.bzl +++ b/python/private/local_runtime_repo.bzl @@ -85,7 +85,15 @@ def _local_runtime_repo_impl(rctx): logger.info(lambda: _format_get_info_result(info)) # NOTE: Keep in sync with recursive glob in define_local_runtime_toolchain_impl - repo_utils.watch_tree(rctx, rctx.path(info["include"])) + include_path = rctx.path(info["include"]) + + # The reported include path may not exist, and watching a non-existant + # path is an error. Silently skip, since includes are only necessary + # if C extensions are built. + if include_path.exists and include_path.is_dir: + repo_utils.watch_tree(rctx, include_path) + else: + pass # The cc_library.includes values have to be non-absolute paths, otherwise # the toolchain will give an error. Work around this error by making them From da8098afbf031786e10dc7e7b054d0e96bbfc5e6 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Wed, 13 Aug 2025 17:25:44 +0000 Subject: [PATCH 2/4] rm changelog deltas --- CHANGELOG.md | 127 --------------------------------------------------- 1 file changed, 127 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a297989f4..cf9adba1b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,133 +47,6 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> -{#v0-0-0} -## Unreleased - -[0.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.0.0 - -{#v0-0-0-changed} -### Changed -* (gazelle) For package mode, resolve dependencies when imports are relative - to the package path. This is enabled via the - `# gazelle:experimental_allow_relative_imports` true directive ({gh-issue}`2203`). -* (gazelle) Types for exposed members of `python.ParserOutput` are now all public. -* (gazelle) Removed the requirement for `__init__.py`, `__main__.py`, or `__test__.py` files to be - present in a directory to generate a `BUILD.bazel` file. -* (toolchain) Updated the following toolchains to build 20250612 to patch CVE-2025-47273: - * 3.9.23 - * 3.10.18 - * 3.11.13 - * 3.12.11 - * 3.14.0b2 -* (toolchain) Python 3.13 now references 3.13.5 - -{#v0-0-0-fixed} -### Fixed -* (pypi) Fixes an issue where builds using a `bazel vendor` vendor directory - would fail if the constraints file contained environment markers. Fixes - [#2996](https://github.com/bazel-contrib/rules_python/issues/2996). -* (pypi) Wheels with BUILD.bazel (or other special Bazel files) no longer - result in missing files at runtime - ([#2782](https://github.com/bazel-contrib/rules_python/issues/2782)). -* (runfiles) The pypi runfiles package now includes `py.typed` to indicate it - supports type checking - ([#2503](https://github.com/bazel-contrib/rules_python/issues/2503)). -* (toolchains) `local_runtime_repo` now checks if the include directory exists - before attempting to watch it, fixing issues on macOS with system Python - ({gh-issue}`3043`). - -{#v0-0-0-added} -### Added -* (pypi) To configure the environment for `requirements.txt` evaluation, use the newly added - developer preview of the `pip.default` tag class. Only `rules_python` and root modules can use - this feature. You can also configure custom `config_settings` using `pip.default`. -* (gazelle) New directive `gazelle:python_generate_pyi_deps`; when `true`, - dependencies added to satisfy type-only imports (`if TYPE_CHECKING`) and type - stub packages are added to `pyi_deps` instead of `deps`. - -{#v0-0-0-removed} -### Removed -* Nothing removed. - -{#1-5-0} -## [1.5.0] - 2025-06-11 - -[1.5.0]: https://github.com/bazel-contrib/rules_python/releases/tag/1.5.0 - -{#1-5-0-changed} -### Changed - -* (toolchain) Bundled toolchain version updates: - * 3.9 now references 3.9.23 - * 3.10 now references 3.10.18 - * 3.11 now references 3.11.13 - * 3.12 now references 3.12.11 - * 3.13 now references 3.13.4 -* (rules) On Windows, {obj}`--bootstrap_impl=system_python` is forced. This - allows setting `--bootstrap_impl=script` in bazelrc for mixed-platform - environments. -* (rules) {obj}`compile_pip_requirements` now generates a `.test` target. The - `_test` target is deprecated and will be removed in the next major release. - ([#2794](https://github.com/bazel-contrib/rules_python/issues/2794) -* (py_wheel) py_wheel always creates zip64-capable wheel zips -* (providers) (experimental) {obj}`PyInfo.venv_symlinks` replaces - `PyInfo.site_packages_symlinks` -* (deps) Updated setuptools to 78.1.1 to patch CVE-2025-47273. This effectively makes - Python 3.9 the minimum supported version for using `pip_parse`. - -{#1-5-0-fixed} -### Fixed - -* (rules) PyInfo provider is now advertised by py_test, py_binary, and py_library; - this allows aspects using required_providers to function correctly. - ([#2506](https://github.com/bazel-contrib/rules_python/issues/2506)). -* Fixes when using {obj}`--bootstrap_impl=script`: - * `compile_pip_requirements` now works with it - * The `sys._base_executable` value will reflect the underlying interpreter, - not venv interpreter. - * The {obj}`//python/runtime_env_toolchains:all` toolchain now works with it. -* (rules) Better handle flakey platform.win32_ver() calls by calling them - multiple times. -* (tools/wheelmaker.py) Extras are now preserved in Requires-Dist metadata when using requires_file - to specify the requirements. -* (pypi) Use bazel downloader for direct URL references and correctly detect the filenames from - various URL formats - URL encoded version strings get correctly resolved, sha256 value can be - also retrieved from the URL as opposed to only the `--hash` parameter. Fixes - [#2363](https://github.com/bazel-contrib/rules_python/issues/2363). -* (pypi) `whl_library` now infers file names from its `urls` attribute correctly. -* (pypi) When running under `bazel test`, be sure that temporary `requirements` file - remains writable. -* (py_test, py_binary) Allow external files to be used for main -* (pypi) Correctly aggregate the sources when the hashes specified in the lockfile differ - by platform even though the same version is used. Fixes [#2648](https://github.com/bazel-contrib/rules_python/issues/2648). -* (pypi) `compile_pip_requirements` test rule works behind the proxy -* (toolchains) The hermetic toolchains now correctly statically advertise the - `releaselevel` and `serial` for pre-release hermetic toolchains ({gh-issue}`2837`). - -{#1-5-0-added} -### Added -* Repo utilities `execute_unchecked`, `execute_checked`, and `execute_checked_stdout` now - support `log_stdout` and `log_stderr` keyword arg booleans. When these are `True` - (the default), the subprocess's stdout/stderr will be logged. -* (toolchains) Local toolchains can be activated with custom flags. See - [Conditionally using local toolchains] docs for how to configure. -* (pypi) Starlark-based evaluation of environment markers (requirements.txt conditionals) - available (not enabled by default) for improved multi-platform build support. - Set the `RULES_PYTHON_ENABLE_PIPSTAR=1` environment variable to enable it. -* (utils) Add a way to run a REPL for any `rules_python` target that returns - a `PyInfo` provider. -* (uv) Handle `.netrc` and `auth_patterns` auth when downloading `uv`. Work towards - [#1975](https://github.com/bazel-contrib/rules_python/issues/1975). -* (toolchains) Arbitrary python-build-standalone runtimes can be registered - and activated with custom flags. See the [Registering custom runtimes] - docs and {obj}`single_version_platform_override()` API docs for more - information. -* (rules) Added support for a using constraints files with `compile_pip_requirements`. - Useful when an intermediate dependency needs to be upgraded to pull in - security patches. -* (toolchains): 3.14.0b2 has been added as a preview. - {#1-5-0-removed} ### Removed * Nothing removed. From 8acdb8212f004e4cbf18f41b30ca974cb555f01e Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Wed, 13 Aug 2025 17:26:29 +0000 Subject: [PATCH 3/4] one more changelog tweak --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9adba1b6..5e839d3103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,9 +47,6 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> -{#1-5-0-removed} -### Removed -* Nothing removed. {#1-4-1} ## [1.4.1] - 2025-05-08 From a20097f1395e2760096809e90a662070f94fba11 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Wed, 13 Aug 2025 17:33:53 +0000 Subject: [PATCH 4/4] add 1.4.2 changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e839d3103..554723fd29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,17 @@ END_UNRELEASED_TEMPLATE --> +{#1-4-2} +## [1.4.2] - 2025-08-13 + +[1.4.2]: https://github.com/bazel-contrib/rules_python/releases/tag/1.4.2 + +### Fixed +* (toolchains) `local_runtime_repo` now checks if the include directory exists + before attempting to watch it, fixing issues on macOS with system Python + ([#3043](https://github.com/bazel-contrib/rules_python/issues/3043)). + + {#1-4-1} ## [1.4.1] - 2025-05-08