Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent sys.prefix from leaking into child process on macOS #1648

Merged
merged 4 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog/1643.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix cross interpreter support when the host python sets ``sys.base_executable`` based on ``__PYVENV_LAUNCHER__`` -
by :user:`cjolowicz`
11 changes: 10 additions & 1 deletion src/virtualenv/discovery/cached_py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,21 @@ def _get_fs_path():
def _run_subprocess(cls, exe):
resolved_path = Path(os.path.abspath(__file__)).parent / "py_info.py"
with ensure_file_on_disk(resolved_path) as resolved_path:

cmd = [exe, "-s", str(resolved_path)]
# prevent sys.prefix from leaking into the child process - see https://bugs.python.org/issue22490
env = os.environ.copy()
env.pop("__PYVENV_LAUNCHER__", None)

logging.debug("get interpreter info via cmd: %s", LogCmd(cmd))
try:
process = Popen(
cmd, universal_newlines=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE
cmd,
universal_newlines=True,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
env=env,
)
out, err = process.communicate()
code = process.returncode
Expand Down