Skip to content

Commit 66f255a

Browse files
committed
cleanup
1 parent d3a6d37 commit 66f255a

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

python/private/stage1_bootstrap_template.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set -e
55
if [[ -n "${RULES_PYTHON_BOOTSTRAP_VERBOSE:-}" ]]; then
66
set -x
77
fi
8-
## set -x
98

109
# runfiles-relative path
1110
STAGE2_BOOTSTRAP="%stage2_bootstrap%"
@@ -147,7 +146,6 @@ if [[ "$IS_ZIPFILE" == "1" ]]; then
147146
mkdir -p "$(dirname $python_exe)"
148147
ln -s "$symlink_to" "$python_exe"
149148
elif [[ "$RECREATE_VENV_AT_RUNTIME" == "1" ]]; then
150-
runfiles_venv="$RUNFILES_DIR/$(dirname $(dirname $PYTHON_BINARY))"
151149

152150
if [[ -n "$RULES_PYTHON_EXTRACT_ROOT" ]]; then
153151
use_exec=1
@@ -166,9 +164,9 @@ elif [[ "$RECREATE_VENV_AT_RUNTIME" == "1" ]]; then
166164
fi
167165

168166
# Match the basename; some tools, e.g. pyvenv key off the executable name
169-
venv_py_exe="$venv/bin/$(basename $PYTHON_BINARY_ACTUAL)"
167+
python_exe="$venv/bin/$(basename $PYTHON_BINARY_ACTUAL)"
170168

171-
if [[ ! -e "$venv_py_exe" ]]; then
169+
if [[ ! -e "$python_exe" ]]; then
172170
if [[ "$PYTHON_BINARY_ACTUAL" == /* ]]; then
173171
# An absolute path, i.e. platform runtime, e.g. /usr/bin/python3
174172
symlink_to=$PYTHON_BINARY_ACTUAL
@@ -185,6 +183,7 @@ elif [[ "$RECREATE_VENV_AT_RUNTIME" == "1" ]]; then
185183
fi
186184
fi
187185

186+
runfiles_venv="$RUNFILES_DIR/$(dirname $(dirname $PYTHON_BINARY))"
188187
# When RESOLVE_PYTHON_BINARY_AT_RUNTIME is true, it means the toolchain
189188
# has thrown two complications at us:
190189
# 1. The build-time assumption of the Python version may not match the
@@ -230,7 +229,6 @@ EOF
230229
if [[ ! -e "$venv/pyvenv.cfg" ]]; then
231230
ln -s "$runfiles_venv/pyvenv.cfg" "$venv/pyvenv.cfg"
232231
fi
233-
234232
else
235233
use_exec=1
236234
fi

tests/runtime_env_toolchain/toolchain_runs_test.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,15 @@
33
import platform
44
import unittest
55

6+
from python.runfiles import runfiles
67

78
class RunTest(unittest.TestCase):
89
def test_ran(self):
9-
import os
10-
##os.system("which python3")
11-
##for x, y in sorted(os.environ.items()):
12-
## print(f"{x}={y}")
13-
import sys
14-
print(f"{sys.executable=}")
15-
print(f"{sys.prefix=}")
16-
print(f"{sys.base_prefix=}")
17-
for i, x in enumerate(sys.path):
18-
print(i, x)
19-
20-
##todo trying to get bazel to use py 3.9
21-
## Use pyenv global to change the version used when shell isn't
22-
## inherited
23-
##print(sys.base_executable)
24-
print(sys.version)
25-
from python.runfiles import runfiles
2610
rf = runfiles.Create()
2711
settings_path = rf.Rlocation(
2812
"rules_python/tests/support/current_build_settings.json"
2913
)
3014
settings = json.loads(pathlib.Path(settings_path).read_text())
31-
print(settings)
3215
if platform.system() == "Windows":
3316
self.assertEqual(
3417
"/_magic_pyruntime_sentinel_do_not_use", settings["interpreter_path"]

0 commit comments

Comments
 (0)