From 54710cb9ab37990b4b503d20b0eca0a91609d19f Mon Sep 17 00:00:00 2001 From: Morten Mjelva Date: Tue, 17 Sep 2024 14:40:10 +0200 Subject: [PATCH 1/3] Prefix bootstrap file to prevent pytest reentrance --- python/private/common/py_executable_bazel.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/private/common/py_executable_bazel.bzl b/python/private/common/py_executable_bazel.bzl index a0cfebad8a..67de5d2781 100644 --- a/python/private/common/py_executable_bazel.bzl +++ b/python/private/common/py_executable_bazel.bzl @@ -330,7 +330,7 @@ def _create_stage2_bootstrap( imports, runtime_details): output = ctx.actions.declare_file( - "{}_stage2_bootstrap.py".format(output_prefix), + "_{}_stage2_bootstrap.py".format(output_prefix), sibling = output_sibling, ) runtime = runtime_details.effective_runtime From 3292c16be1f21638cbb6dca8778a10d40abd5417 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 17 Sep 2024 13:40:33 -0700 Subject: [PATCH 2/3] Update python/private/common/py_executable_bazel.bzl --- python/private/common/py_executable_bazel.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/private/common/py_executable_bazel.bzl b/python/private/common/py_executable_bazel.bzl index 67de5d2781..dae1c4a0b1 100644 --- a/python/private/common/py_executable_bazel.bzl +++ b/python/private/common/py_executable_bazel.bzl @@ -330,6 +330,8 @@ def _create_stage2_bootstrap( imports, runtime_details): output = ctx.actions.declare_file( + # Prepend with underscore to prevent pytest from trying to + # process the bootstrap for files starting with `test_` "_{}_stage2_bootstrap.py".format(output_prefix), sibling = output_sibling, ) From 8a218c3cf9df531b3d8c08ae403338545644918e Mon Sep 17 00:00:00 2001 From: Morten Mjelva Date: Tue, 17 Sep 2024 22:47:52 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32e3902aff..0300824bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,8 @@ A brief description of the categories of changes: ([#2186](https://github.com/bazelbuild/rules_python/issues/2186)). * (py_wheel) Fix incorrectly generated `Required-Dist` when specifying requirements with markers in extra_requires in py_wheel rule. +* (rules) Prevent pytest from trying run the generated stage2 + bootstrap .py file when using {obj}`--bootstrap_impl=script` ### Added