From 34051e073d825b55fbe47b757379697007d0d541 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Thu, 3 Jul 2025 18:02:17 -0700 Subject: [PATCH] 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> (cherry picked from commit be55942a16b49fbafa63d0e26ab445c0dd5ca2ca) --- CHANGELOG.md | 12 ++++++++++++ python/private/local_runtime_repo.bzl | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaa95d06a1..48bb97f644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,17 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> +{#1-5-3} +## [1.5.3] - 2025-08-11 + +[1.5.3]: https://github.com/bazel-contrib/rules_python/releases/tag/1.5.3 + +{#v1-5-3-fixed} +### Fixed +* (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`). + {#1-5-2} ## [1.5.2] - 2025-08-11 @@ -65,6 +76,7 @@ END_UNRELEASED_TEMPLATE * (core) builds work again on `7.x` `WORKSPACE` configurations ([#3119](https://github.com/bazel-contrib/rules_python/issues/3119)). + {#1-5-1} ## [1.5.1] - 2025-07-06 diff --git a/python/private/local_runtime_repo.bzl b/python/private/local_runtime_repo.bzl index ec0643e497..3b4b4c020d 100644 --- a/python/private/local_runtime_repo.bzl +++ b/python/private/local_runtime_repo.bzl @@ -99,7 +99,15 @@ def _local_runtime_repo_impl(rctx): interpreter_path = info["base_executable"] # 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