Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e06b4ba

Browse filesBrowse files
fix: fix launching Python 3.11 from <3.8 on macOS (bazel-contrib#1709)
On macOS, some older versions of Python leak __PYVENV_LAUNCHER__ into the interpreter's environment variables. Starting with Python 3.11, this causes problems with Python being able to start correctly when launched from the Python bootstrap template. This change introduces a workaround to prevent the problematic environment variable from leaking into launched subprocesses. I've verified this problem exists with the version of Python 3.7 included with Xcode, and there are reports of it also being an issue with the Python 3.8 included with Xcode. Later versions of Python have fixed this. Context: - https://issues.pigweed.dev/310293060 - xonsh/xonsh#3576 (comment) - pypa/virtualenv#1458
1 parent a64e55b commit e06b4ba
Copy full SHA for e06b4ba

File tree

Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed

‎python/private/python_bootstrap_template.txt

Copy file name to clipboardExpand all lines: python/private/python_bootstrap_template.txt
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,13 @@ def Main():
528528
else:
529529
cov_tool = None
530530

531+
# Some older Python versions on macOS (namely Python 3.7) may unintentionally
532+
# leave this environment variable set after starting the interpreter, which
533+
# causes problems with Python subprocesses correctly locating sys.executable,
534+
# which subsequently causes failure to launch on Python 3.11 and later.
535+
if '__PYVENV_LAUNCHER__' in os.environ:
536+
del os.environ['__PYVENV_LAUNCHER__']
537+
531538
new_env.update((key, val) for key, val in os.environ.items() if key not in new_env)
532539

533540
workspace = None

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.