|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. |
| 2 | + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. |
3 | 3 | * Copyright (c) 2014, Regents of the University of California
|
4 | 4 | *
|
5 | 5 | * All rights reserved.
|
@@ -287,9 +287,17 @@ public void postInitialize(PythonCore core) {
|
287 | 287 | Map<String, String> getenv = System.getenv();
|
288 | 288 | PDict environ = core.factory().createDict();
|
289 | 289 | 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())); |
291 | 300 | }
|
292 |
| - |
293 | 301 | PythonModule posix = core.lookupBuiltinModule("posix");
|
294 | 302 | Object environAttr = posix.getAttribute("environ");
|
295 | 303 | ((PDict) environAttr).setDictStorage(environ.getDictStorage());
|
|
0 commit comments