Skip to content

Commit b7122ce

Browse files
committed
full fix
1 parent 726d780 commit b7122ce

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ END_UNRELEASED_TEMPLATE
8686

8787
{#v0-0-0-fixed}
8888
### Fixed
89+
* (bootstrap) The stage1 bootstrap script now correctly handles nested `RUNFILES_DIR`
90+
environments, fixing issues where a `py_binary` calls another `py_binary`
91+
([#3187](https://github.com/bazel-contrib/rules_python/issues/3187)).
8992
* (pypi) Fixes an issue where builds using a `bazel vendor` vendor directory
9093
would fail if the constraints file contained environment markers. Fixes
9194
[#2996](https://github.com/bazel-contrib/rules_python/issues/2996).

python/private/python_bootstrap_template.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ def Main():
516516
if os.environ.get("RULES_PYTHON_TESTING_TELL_MODULE_SPACE"):
517517
new_env["RULES_PYTHON_TESTING_MODULE_SPACE"] = module_space
518518

519-
print(f"===== module space: {module_space}")
520519
python_imports = '%imports%'
521520
python_path_entries = CreatePythonPathEntries(python_imports, module_space)
522521
python_path_entries += GetRepositoriesImports(module_space, %import_all%)
@@ -539,7 +538,6 @@ def Main():
539538
new_env['PYTHONPATH'] = python_path
540539
runfiles_envkey, runfiles_envvalue = RunfilesEnvvar(module_space)
541540
if runfiles_envkey:
542-
print(f"===== setting {runfiles_envkey} = {runfiles_envvalue}")
543541
new_env[runfiles_envkey] = runfiles_envvalue
544542

545543
# Don't prepend a potentially unsafe path to sys.path

python/private/stage1_bootstrap_template.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ else
7070
maybe_root="${RUNFILES_MANIFEST_FILE%%.runfiles/MANIFEST}.runfiles"
7171
fi
7272

73+
# The RUNFILES_DIR et al variables may misreport the runfiles directory
74+
# if an outer binary invokes this binary when it isn't a data dependency.
75+
# e.g. a genrule calls `bazel-bin/outer --inner=bazel-bin/inner`
7376
if [[ -n "$maybe_root" && -e "$maybe_root/$STAGE2_BOOTSTRAP" ]]; then
7477
echo "$maybe_root"
7578
return 0
@@ -102,6 +105,9 @@ else
102105
RUNFILES_DIR=$(find_runfiles_root $0)
103106
fi
104107

108+
if [[ -n "$RULES_PYTHON_TESTING_TELL_MODULE_SPACE" ]]; then
109+
export RULES_PYTHON_TESTING_MODULE_SPACE="$RUNFILES_DIR"
110+
fi
105111

106112
function find_python_interpreter() {
107113
runfiles_root="$1"

0 commit comments

Comments
 (0)