From 10ea71d79994a7bbd1c3a62a5f61f2289ac5cfc2 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 19:06:20 -0800 Subject: [PATCH 01/19] disable build_python_zip --- .bazelrc | 4 ++++ examples/build_file_generation/.bazelrc | 4 ++++ examples/bzlmod/.bazelrc | 4 ++++ examples/multi_python_versions/.bazelrc | 4 ++++ examples/pip_parse/.bazelrc | 4 ++++ examples/pip_parse_vendored/.bazelrc | 4 ++++ examples/pip_repository_annotations/.bazelrc | 4 ++++ gazelle/.bazelrc | 4 ++++ gazelle/examples/bzlmod_build_file_generation/.bazelrc | 4 ++++ tests/integration/compile_pip_requirements/.bazelrc | 4 ++++ .../compile_pip_requirements_test_from_external_repo/.bazelrc | 4 ++++ tests/integration/local_toolchains/.bazelrc | 4 ++++ tests/integration/pip_parse/.bazelrc | 4 ++++ tests/integration/py_cc_toolchain_registered/.bazelrc | 4 ++++ 14 files changed, 56 insertions(+) diff --git a/.bazelrc b/.bazelrc index 24676574e6..2545f30f80 100644 --- a/.bazelrc +++ b/.bazelrc @@ -41,3 +41,7 @@ common --incompatible_python_disallow_native_rules common --incompatible_no_implicit_file_export build --lockfile_mode=update + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false diff --git a/examples/build_file_generation/.bazelrc b/examples/build_file_generation/.bazelrc index f1ae44fac8..e14ed7c9f6 100644 --- a/examples/build_file_generation/.bazelrc +++ b/examples/build_file_generation/.bazelrc @@ -8,3 +8,7 @@ build --enable_runfiles common --noenable_bzlmod common --enable_workspace common --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/examples/bzlmod/.bazelrc b/examples/bzlmod/.bazelrc index 28a44a7523..a18c7e2551 100644 --- a/examples/bzlmod/.bazelrc +++ b/examples/bzlmod/.bazelrc @@ -24,3 +24,7 @@ test --test_output=errors --enable_runfiles # Windows requires these for multi-python support: build --enable_runfiles common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/examples/multi_python_versions/.bazelrc b/examples/multi_python_versions/.bazelrc index 97a973bd85..39ed55aff4 100644 --- a/examples/multi_python_versions/.bazelrc +++ b/examples/multi_python_versions/.bazelrc @@ -5,3 +5,7 @@ build --enable_runfiles coverage --java_runtime_version=remotejdk_11 common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/examples/pip_parse/.bazelrc b/examples/pip_parse/.bazelrc index f263a1744d..0df6cdc90b 100644 --- a/examples/pip_parse/.bazelrc +++ b/examples/pip_parse/.bazelrc @@ -1,3 +1,7 @@ # https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file try-import %workspace%/user.bazelrc common --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false diff --git a/examples/pip_parse_vendored/.bazelrc b/examples/pip_parse_vendored/.bazelrc index a6ea2d9138..e846b1ac11 100644 --- a/examples/pip_parse_vendored/.bazelrc +++ b/examples/pip_parse_vendored/.bazelrc @@ -8,3 +8,7 @@ build --enable_runfiles common --noenable_bzlmod common --enable_workspace common --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/examples/pip_repository_annotations/.bazelrc b/examples/pip_repository_annotations/.bazelrc index 9397bd31b8..82c7a1dbd2 100644 --- a/examples/pip_repository_annotations/.bazelrc +++ b/examples/pip_repository_annotations/.bazelrc @@ -7,3 +7,7 @@ common --noenable_bzlmod common --enable_workspace common --legacy_external_runfiles=false common --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc index 9a38133e9d..0f46b5b584 100644 --- a/gazelle/.bazelrc +++ b/gazelle/.bazelrc @@ -16,3 +16,7 @@ build --@rules_python//python/config_settings:incompatible_default_to_explicit_i build --enable_runfiles common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/gazelle/examples/bzlmod_build_file_generation/.bazelrc b/gazelle/examples/bzlmod_build_file_generation/.bazelrc index 31097b41de..5ab484ee67 100644 --- a/gazelle/examples/bzlmod_build_file_generation/.bazelrc +++ b/gazelle/examples/bzlmod_build_file_generation/.bazelrc @@ -14,3 +14,7 @@ common:bazel7.x --incompatible_python_disallow_native_rules # rules_python code. In the BCR presubmits, this override is removed # and the bazel_dep version of rules_python is used. common --override_module=rules_python=../../../ + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/tests/integration/compile_pip_requirements/.bazelrc b/tests/integration/compile_pip_requirements/.bazelrc index b85f03bcb6..be2ceedf66 100644 --- a/tests/integration/compile_pip_requirements/.bazelrc +++ b/tests/integration/compile_pip_requirements/.bazelrc @@ -3,3 +3,7 @@ test --test_output=errors # Windows requires these for multi-python support: build --enable_runfiles common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc b/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc index ab10c8caf7..80d2b0d97d 100644 --- a/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc +++ b/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc @@ -1,2 +1,6 @@ test --test_output=errors common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/tests/integration/local_toolchains/.bazelrc b/tests/integration/local_toolchains/.bazelrc index aed08b0790..6a920b180c 100644 --- a/tests/integration/local_toolchains/.bazelrc +++ b/tests/integration/local_toolchains/.bazelrc @@ -6,3 +6,7 @@ build --enable_runfiles common:bazel7.x --incompatible_python_disallow_native_rules build --//:py=local common --announce_rc + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/tests/integration/pip_parse/.bazelrc b/tests/integration/pip_parse/.bazelrc index a74909297d..3d3d8bd67f 100644 --- a/tests/integration/pip_parse/.bazelrc +++ b/tests/integration/pip_parse/.bazelrc @@ -6,3 +6,7 @@ build --enable_runfiles try-import %workspace%/user.bazelrc common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file diff --git a/tests/integration/py_cc_toolchain_registered/.bazelrc b/tests/integration/py_cc_toolchain_registered/.bazelrc index fb31561892..e5a95490e6 100644 --- a/tests/integration/py_cc_toolchain_registered/.bazelrc +++ b/tests/integration/py_cc_toolchain_registered/.bazelrc @@ -1,3 +1,7 @@ # This aids debugging on failure build --toolchain_resolution_debug=python common:bazel7.x --incompatible_python_disallow_native_rules + +# See issue 3567. Disable implicit python zip creation. +common --build_python_zip=false +common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file From 1df83812e77549b7bcdb3001e0ad33cd66b328f8 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 19:11:02 -0800 Subject: [PATCH 02/19] add empty line to make bcr test happy? --- examples/bzlmod/.bazelrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/bzlmod/.bazelrc b/examples/bzlmod/.bazelrc index a18c7e2551..f398c424bf 100644 --- a/examples/bzlmod/.bazelrc +++ b/examples/bzlmod/.bazelrc @@ -27,4 +27,5 @@ common:bazel7.x --incompatible_python_disallow_native_rules # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false -common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file +common --@rules_python//python/config_settings:build_python_zip=false + From e7d15f78dc27270382b14e442b413812ccabab30 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 19:33:00 -0800 Subject: [PATCH 03/19] more debugging --- python/private/stage2_bootstrap_template.py | 2 ++ tests/build_data/print_build_data.py | 1 + 2 files changed, 3 insertions(+) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index c03a4a2e62..1edd1e9fd3 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -77,6 +77,8 @@ def get_build_data(self): if hasattr(exc, "add_note"): exc.add_note(f"runfiles lookup path: {rlocation_path}") exc.add_note(f"exists: {os.path.exists(path)}") + exc.add_note(f"lexists: {os.path.lexists(path)}") + exc.add_note(f"islink: {os.path.islink(path)}") can_read = os.access(path, os.R_OK) exc.add_note(f"readable: {can_read}") raise diff --git a/tests/build_data/print_build_data.py b/tests/build_data/print_build_data.py index 0af77d72be..2569806b1c 100644 --- a/tests/build_data/print_build_data.py +++ b/tests/build_data/print_build_data.py @@ -1,3 +1,4 @@ import bazel_binary_info +print(bazel_binary_info) print(bazel_binary_info.get_build_data()) From a5e6fec9c11b4e0ee1dc07138376c3d484b8af16 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 19:45:14 -0800 Subject: [PATCH 04/19] split binary from text portion --- python/private/stage2_bootstrap_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 1edd1e9fd3..cce4ce62c5 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -71,8 +71,9 @@ def get_build_data(self): path = os.path.normpath(path) try: # Use utf-8-sig to handle Windows BOM - with open(path, encoding="utf-8-sig") as fp: - return fp.read() + with open(path, 'rb') as fp: + data = fp.read() + return data.decode('utf-8-sig') except Exception as exc: if hasattr(exc, "add_note"): exc.add_note(f"runfiles lookup path: {rlocation_path}") From cf607e0b50ee9bebd2b3cb1ba5f03d19a98eca89 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 19:48:23 -0800 Subject: [PATCH 05/19] print if its a junction --- python/private/stage2_bootstrap_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index cce4ce62c5..bc368b5447 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -80,6 +80,7 @@ def get_build_data(self): exc.add_note(f"exists: {os.path.exists(path)}") exc.add_note(f"lexists: {os.path.lexists(path)}") exc.add_note(f"islink: {os.path.islink(path)}") + exc.add_note(f"isjunction: {os.path.isjunction(path)}") can_read = os.access(path, os.R_OK) exc.add_note(f"readable: {can_read}") raise From 7f4fd54f7aaae98946c93174ae6abae4b25aed29 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 19:52:44 -0800 Subject: [PATCH 06/19] use py 3.14 for test for isjunction --- tests/build_data/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/build_data/BUILD.bazel b/tests/build_data/BUILD.bazel index 64db005f51..0f427a1042 100644 --- a/tests/build_data/BUILD.bazel +++ b/tests/build_data/BUILD.bazel @@ -14,6 +14,7 @@ py_test( py_binary( name = "print_build_data", srcs = ["print_build_data.py"], + python_version = "3.14", deps = ["//python/runfiles"], ) From ed75abff9144a0ed8de074ceec463dc673ea0008 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 20:16:23 -0800 Subject: [PATCH 07/19] use py3.10 --- python/private/stage2_bootstrap_template.py | 3 ++- tests/build_data/BUILD.bazel | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index bc368b5447..863c93cab5 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -80,7 +80,8 @@ def get_build_data(self): exc.add_note(f"exists: {os.path.exists(path)}") exc.add_note(f"lexists: {os.path.lexists(path)}") exc.add_note(f"islink: {os.path.islink(path)}") - exc.add_note(f"isjunction: {os.path.isjunction(path)}") + if hasattr(os.path, "isjunction"): + exc.add_note(f"isjunction: {os.path.isjunction(path)}") can_read = os.access(path, os.R_OK) exc.add_note(f"readable: {can_read}") raise diff --git a/tests/build_data/BUILD.bazel b/tests/build_data/BUILD.bazel index 0f427a1042..7fcef6f6a9 100644 --- a/tests/build_data/BUILD.bazel +++ b/tests/build_data/BUILD.bazel @@ -14,7 +14,7 @@ py_test( py_binary( name = "print_build_data", srcs = ["print_build_data.py"], - python_version = "3.14", + python_version = "3.10", deps = ["//python/runfiles"], ) From 4032e485ab90d4a89752868abc5a0384e29572eb Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 20:34:54 -0800 Subject: [PATCH 08/19] bump gazelle to rules_python 1.7 --- gazelle/examples/bzlmod_build_file_generation/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gazelle/examples/bzlmod_build_file_generation/MODULE.bazel b/gazelle/examples/bzlmod_build_file_generation/MODULE.bazel index 1f92ea3826..7db658fcec 100644 --- a/gazelle/examples/bzlmod_build_file_generation/MODULE.bazel +++ b/gazelle/examples/bzlmod_build_file_generation/MODULE.bazel @@ -13,7 +13,7 @@ module( # For typical setups you set the version. # See the releases page for available versions. # https://github.com/bazel-contrib/rules_python/releases -bazel_dep(name = "rules_python", version = "1.4.0") +bazel_dep(name = "rules_python", version = "1.7.0") # The following stanza defines the dependency rules_python_gazelle_plugin. # For typical setups you set the version. From 9e146d2062aa0bcecc9ecdc1604b9eead14a67b9 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 20:40:36 -0800 Subject: [PATCH 09/19] add empty newlines to bazelrc --- gazelle/.bazelrc | 5 ++++- gazelle/examples/bzlmod_build_file_generation/.bazelrc | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc index 0f46b5b584..fa21d59e31 100644 --- a/gazelle/.bazelrc +++ b/gazelle/.bazelrc @@ -19,4 +19,7 @@ common:bazel7.x --incompatible_python_disallow_native_rules # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false -common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file +common --@rules_python//python/config_settings:build_python_zip=false + +# Empty newline + diff --git a/gazelle/examples/bzlmod_build_file_generation/.bazelrc b/gazelle/examples/bzlmod_build_file_generation/.bazelrc index 5ab484ee67..27c871e442 100644 --- a/gazelle/examples/bzlmod_build_file_generation/.bazelrc +++ b/gazelle/examples/bzlmod_build_file_generation/.bazelrc @@ -17,4 +17,7 @@ common --override_module=rules_python=../../../ # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false -common --@rules_python//python/config_settings:build_python_zip=false \ No newline at end of file +common --@rules_python//python/config_settings:build_python_zip=false + +# Empty newline + From bcb10e37433f63dd5ec84391c91a86c713979140 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 20:48:22 -0800 Subject: [PATCH 10/19] debug --- python/private/stage2_bootstrap_template.py | 1 + tests/build_data/BUILD.bazel | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 863c93cab5..aca97eb3b3 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -73,6 +73,7 @@ def get_build_data(self): # Use utf-8-sig to handle Windows BOM with open(path, 'rb') as fp: data = fp.read() + raise Exception("bogus") return data.decode('utf-8-sig') except Exception as exc: if hasattr(exc, "add_note"): diff --git a/tests/build_data/BUILD.bazel b/tests/build_data/BUILD.bazel index 7fcef6f6a9..47788afa10 100644 --- a/tests/build_data/BUILD.bazel +++ b/tests/build_data/BUILD.bazel @@ -14,7 +14,7 @@ py_test( py_binary( name = "print_build_data", srcs = ["print_build_data.py"], - python_version = "3.10", + python_version = "3.12", deps = ["//python/runfiles"], ) From 7001c1c79e21e8062e98c5f6726b14f9c33e42a3 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 20:54:15 -0800 Subject: [PATCH 11/19] remove some debug code --- python/private/stage2_bootstrap_template.py | 1 - tests/build_data/BUILD.bazel | 1 - tests/build_data/print_build_data.py | 1 - 3 files changed, 3 deletions(-) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index aca97eb3b3..863c93cab5 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -73,7 +73,6 @@ def get_build_data(self): # Use utf-8-sig to handle Windows BOM with open(path, 'rb') as fp: data = fp.read() - raise Exception("bogus") return data.decode('utf-8-sig') except Exception as exc: if hasattr(exc, "add_note"): diff --git a/tests/build_data/BUILD.bazel b/tests/build_data/BUILD.bazel index 47788afa10..64db005f51 100644 --- a/tests/build_data/BUILD.bazel +++ b/tests/build_data/BUILD.bazel @@ -14,7 +14,6 @@ py_test( py_binary( name = "print_build_data", srcs = ["print_build_data.py"], - python_version = "3.12", deps = ["//python/runfiles"], ) diff --git a/tests/build_data/print_build_data.py b/tests/build_data/print_build_data.py index 2569806b1c..0af77d72be 100644 --- a/tests/build_data/print_build_data.py +++ b/tests/build_data/print_build_data.py @@ -1,4 +1,3 @@ import bazel_binary_info -print(bazel_binary_info) print(bazel_binary_info.get_build_data()) From 8bf5bec30ec45bb7fbe79440a5672164dae844f0 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 21:00:38 -0800 Subject: [PATCH 12/19] fix presubmit and echo --- .bcr/gazelle/presubmit.yml | 4 ++++ examples/bzlmod/.bazelrc | 1 - gazelle/.bazelrc | 3 --- gazelle/examples/bzlmod_build_file_generation/.bazelrc | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.bcr/gazelle/presubmit.yml b/.bcr/gazelle/presubmit.yml index 99647cac6f..40226c606d 100644 --- a/.bcr/gazelle/presubmit.yml +++ b/.bcr/gazelle/presubmit.yml @@ -27,10 +27,14 @@ bcr_test_module: platform: ${{ platform }} bazel: ${{ bazel }} shell_commands: + # Add an empty line in case the bazelrc is missing a trailing newline + - "echo '' >> .bazelrc" - "echo 'common --override_module=rules_python=' >> .bazelrc" - "bazel run //:gazelle_python_manifest.update" - "bazel run //:gazelle -- update" batch_commands: + # Add an empty line in case the bazelrc is missing a trailing newline + - "echo '' >> .bazelrc" - "echo common --override_module=rules_python= >> .bazelrc" - "bazel run //:gazelle_python_manifest.update" - "bazel run //:gazelle -- update" diff --git a/examples/bzlmod/.bazelrc b/examples/bzlmod/.bazelrc index f398c424bf..3dd26531f9 100644 --- a/examples/bzlmod/.bazelrc +++ b/examples/bzlmod/.bazelrc @@ -28,4 +28,3 @@ common:bazel7.x --incompatible_python_disallow_native_rules # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false common --@rules_python//python/config_settings:build_python_zip=false - diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc index fa21d59e31..a4cbf2dbfe 100644 --- a/gazelle/.bazelrc +++ b/gazelle/.bazelrc @@ -20,6 +20,3 @@ common:bazel7.x --incompatible_python_disallow_native_rules # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false common --@rules_python//python/config_settings:build_python_zip=false - -# Empty newline - diff --git a/gazelle/examples/bzlmod_build_file_generation/.bazelrc b/gazelle/examples/bzlmod_build_file_generation/.bazelrc index 27c871e442..f9e43556f7 100644 --- a/gazelle/examples/bzlmod_build_file_generation/.bazelrc +++ b/gazelle/examples/bzlmod_build_file_generation/.bazelrc @@ -18,6 +18,3 @@ common --override_module=rules_python=../../../ # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false common --@rules_python//python/config_settings:build_python_zip=false - -# Empty newline - From 0274b81ff4c5e45748bc21e69476ce2727630cc1 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 21:09:28 -0800 Subject: [PATCH 13/19] show version in error --- python/private/stage2_bootstrap_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 863c93cab5..75aeff851b 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -84,6 +84,7 @@ def get_build_data(self): exc.add_note(f"isjunction: {os.path.isjunction(path)}") can_read = os.access(path, os.R_OK) exc.add_note(f"readable: {can_read}") + exc.add_note(f"version: {sys.version}") raise From b9ac47420dc29d9ca26f53e7436d27cb8d8511a5 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 21:15:56 -0800 Subject: [PATCH 14/19] add isfile, stat, lstat --- python/private/stage2_bootstrap_template.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 75aeff851b..2568702982 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -80,10 +80,13 @@ def get_build_data(self): exc.add_note(f"exists: {os.path.exists(path)}") exc.add_note(f"lexists: {os.path.lexists(path)}") exc.add_note(f"islink: {os.path.islink(path)}") + exc.add_note(f"isfile: {os.path.isfile(path)}") if hasattr(os.path, "isjunction"): exc.add_note(f"isjunction: {os.path.isjunction(path)}") can_read = os.access(path, os.R_OK) exc.add_note(f"readable: {can_read}") + exc.add_note(f"stat: {os.stat(path)}") + exc.add_note(f"lstat: {os.lstat(path)}") exc.add_note(f"version: {sys.version}") raise From f3860ce97fec1ee8deef6fcf94fd2dc663418230 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 21:44:24 -0800 Subject: [PATCH 15/19] try using dunder file --- python/private/stage2_bootstrap_template.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 2568702982..c2015f8d17 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -70,12 +70,16 @@ def get_build_data(self): if is_windows(): path = os.path.normpath(path) try: + path = os.path.dirname(__file__) + path = os.path.join(path, "print_build_data.build_data.txt") # Use utf-8-sig to handle Windows BOM with open(path, 'rb') as fp: data = fp.read() return data.decode('utf-8-sig') except Exception as exc: if hasattr(exc, "add_note"): + exc.add_note(f"version: {sys.version}") + exc.add_note(f"path: {path}") exc.add_note(f"runfiles lookup path: {rlocation_path}") exc.add_note(f"exists: {os.path.exists(path)}") exc.add_note(f"lexists: {os.path.lexists(path)}") @@ -87,7 +91,6 @@ def get_build_data(self): exc.add_note(f"readable: {can_read}") exc.add_note(f"stat: {os.stat(path)}") exc.add_note(f"lstat: {os.lstat(path)}") - exc.add_note(f"version: {sys.version}") raise From 0ed36198339857fbbb432c357b561220ce0d882d Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 22:19:41 -0800 Subject: [PATCH 16/19] write unix newlines in build data when generated by windows --- python/private/build_data_writer.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/private/build_data_writer.ps1 b/python/private/build_data_writer.ps1 index 846399f194..32fb7240f1 100644 --- a/python/private/build_data_writer.ps1 +++ b/python/private/build_data_writer.ps1 @@ -18,8 +18,10 @@ if (-not [string]::IsNullOrEmpty($InfoFilePath) -and (Test-Path $InfoFilePath)) # Use .NET to write file to avoid PowerShell encoding/locking quirks # We use UTF8 without BOM for compatibility with how the bash script writes (and # what consumers expect). +# We join with `n to ensure Unix-style line endings are used even on Windows. $Utf8NoBom = New-Object System.Text.UTF8Encoding $False -[System.IO.File]::WriteAllLines($OutputPath, $Lines, $Utf8NoBom) +$Content = [string]::Join("`n", $Lines) + "`n" +[System.IO.File]::WriteAllText($OutputPath, $Content, $Utf8NoBom) $Acl = Get-Acl $OutputPath $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "Read", "Allow") From 381fdf01d0c5c30cb12c4fc42d3f66475a63bf59 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 23:18:36 -0800 Subject: [PATCH 17/19] add dir listing to get_build_data error --- python/private/stage2_bootstrap_template.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index c2015f8d17..0dc2f7e515 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -91,6 +91,10 @@ def get_build_data(self): exc.add_note(f"readable: {can_read}") exc.add_note(f"stat: {os.stat(path)}") exc.add_note(f"lstat: {os.lstat(path)}") + try: + exc.add_note(f"dir: {os.listdir(os.path.dirname(path))}") + except Exception: + pass raise From d3df6314bee956ec4fd945dfb8425d6250867f9a Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 21 Feb 2026 23:23:48 -0800 Subject: [PATCH 18/19] better debugging --- python/private/stage2_bootstrap_template.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 0dc2f7e515..e20a049279 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -89,12 +89,20 @@ def get_build_data(self): exc.add_note(f"isjunction: {os.path.isjunction(path)}") can_read = os.access(path, os.R_OK) exc.add_note(f"readable: {can_read}") - exc.add_note(f"stat: {os.stat(path)}") - exc.add_note(f"lstat: {os.lstat(path)}") try: - exc.add_note(f"dir: {os.listdir(os.path.dirname(path))}") - except Exception: - pass + exc.add_note(f"stat: {os.stat(path)}") + except Exception as e: + exc.add_note(f"stat error: {e}") + try: + exc.add_note(f"lstat: {os.lstat(path)}") + except Exception as e: + exc.add_note(f"lstat error: {e}") + try: + import subprocess + out = subprocess.check_output(f'dir "{os.path.dirname(path)}"', shell=True) + exc.add_note(f"dir: {out.decode('utf-8', 'replace')}") + except Exception as e: + exc.add_note(f"dir error: {e}") raise From 377110127f383110a7e088a34344ba9023fae5e8 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sun, 22 Feb 2026 00:09:27 -0800 Subject: [PATCH 19/19] enable symlinks for windows --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index 2545f30f80..205c04c5ce 100644 --- a/.bazelrc +++ b/.bazelrc @@ -45,3 +45,4 @@ build --lockfile_mode=update # See issue 3567. Disable implicit python zip creation. common --build_python_zip=false common --@rules_python//python/config_settings:build_python_zip=false +startup --windows_enable_symlinks