Skip to content

Commit 9fb13ec

Browse files
authored
fix: run python version call in isolated mode (#2761)
Similar to #2738, runs the call to get the Python interpreter version in isolated mode via `-I`, ensuring userland Python variables do not affect this call.
1 parent 34e433b commit 9fb13ec

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Unreleased changes template.
9191
Fixes [#2685](https://github.com/bazel-contrib/rules_python/issues/2685).
9292
* (toolchains) Run the check on the Python interpreter in isolated mode, to ensure it's not affected by userland environment variables, such as `PYTHONPATH`.
9393
* (toolchains) Ensure temporary `.pyc` and `.pyo` files are also excluded from the interpreters repository files.
94+
* (pypi) Run interpreter version call in isolated mode, to ensure it's not affected by userland environment variables, such as `PYTHONPATH`.
9495

9596
{#v0-0-0-added}
9697
### Added

python/private/pypi/whl_library.bzl

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def _get_toolchain_unix_cflags(rctx, python_interpreter, logger = None):
109109
op = "GetPythonVersionForUnixCflags",
110110
python = python_interpreter,
111111
arguments = [
112+
# Run the interpreter in isolated mode, this options implies -E, -P and -s.
113+
# Ensures environment variables are ignored that are set in userspace, such as PYTHONPATH,
114+
# which may interfere with this invocation.
115+
"-I",
112116
"-c",
113117
"import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}', end='')",
114118
],

0 commit comments

Comments
 (0)