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 diff --git a/python/private/common/py_executable_bazel.bzl b/python/private/common/py_executable_bazel.bzl index a0cfebad8a..dae1c4a0b1 100644 --- a/python/private/common/py_executable_bazel.bzl +++ b/python/private/common/py_executable_bazel.bzl @@ -330,7 +330,9 @@ def _create_stage2_bootstrap( imports, runtime_details): output = ctx.actions.declare_file( - "{}_stage2_bootstrap.py".format(output_prefix), + # 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, ) runtime = runtime_details.effective_runtime