Skip to content

Commit 78ae1f0

Browse files
authored
fix(pypi): harden the WORKSPACE python detection in pip_repository (#3744)
A fixup to #3737
1 parent 588a42b commit 78ae1f0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

python/private/pypi/pip_repository.bzl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@ def _pip_repository_impl(rctx):
9090
python_interpreter = rctx.attr.python_interpreter,
9191
python_interpreter_target = rctx.attr.python_interpreter_target,
9292
)
93-
result = rctx.execute([python_interpreter, "--version"])
94-
if result.stdout:
95-
python_version = result.stdout.strip().split(" ")[-1]
96-
else:
97-
fail("Could not determine Python version")
93+
result = pypi_repo_utils.execute_checked(
94+
rctx,
95+
python = python_interpreter,
96+
srcs = [],
97+
op = "GetPythonVersion",
98+
arguments = ["-c", "import sys; print(sys.version.split()[0])"],
99+
)
100+
python_version = result.stdout.strip().splitlines()[-1]
98101
platforms = [
99102
"linux_aarch64",
100103
"linux_arm",

0 commit comments

Comments
 (0)