Skip to content

Commit b111cda

Browse files
committed
[GR-21110] Overwrite env var __PYVENV_LAUNCHER__ if specified.
PullRequest: graalpython/817
2 parents 53baa0e + 864f5a2 commit b111cda

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "477c6074e14181313e413a599dfcab993cea99c9" }
1+
{ "overlay": "dd8385ad0d13a3be97a71fa9a99f39e5fb20608c" }

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2020, Oracle and/or its affiliates.
33
* Copyright (c) 2014, Regents of the University of California
44
*
55
* All rights reserved.
@@ -287,9 +287,17 @@ public void postInitialize(PythonCore core) {
287287
Map<String, String> getenv = System.getenv();
288288
PDict environ = core.factory().createDict();
289289
for (Entry<String, String> entry : getenv.entrySet()) {
290-
environ.setItem(core.factory().createBytes(entry.getKey().getBytes()), core.factory().createBytes(entry.getValue().getBytes()));
290+
String value;
291+
if ("__PYVENV_LAUNCHER__".equals(entry.getKey())) {
292+
// On Mac, the CPython launcher uses this env variable to specify the real Python
293+
// executable. It will be honored by packages like "site". So, if it is set, we
294+
// overwrite it with our executable to ensure that subprocesses will use us.
295+
value = PythonOptions.getOption(core.getContext(), PythonOptions.Executable);
296+
} else {
297+
value = entry.getValue();
298+
}
299+
environ.setItem(core.factory().createBytes(entry.getKey().getBytes()), core.factory().createBytes(value.getBytes()));
291300
}
292-
293301
PythonModule posix = core.lookupBuiltinModule("posix");
294302
Object environAttr = posix.getAttribute("environ");
295303
((PDict) environAttr).setDictStorage(environ.getDictStorage());

0 commit comments

Comments
 (0)