Skip to content

Commit 9fb13ec

Browse files
authored
fix: run python version call in isolated mode (bazel-contrib#2761)
Similar to bazel-contrib#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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy