Skip to content

Commit 5442fd4

Browse files
committed
Use executable list (w/ relaunch args) for venv launcher.
1 parent 2614150 commit 5442fd4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.List;
5050
import java.util.logging.Level;
5151

52+
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
5253
import org.graalvm.nativeimage.ImageInfo;
5354

5455
import com.oracle.graal.python.PythonLanguage;
@@ -191,6 +192,15 @@ public void postInitialize(PythonCore core) {
191192
false, // dev_mode
192193
0, // utf8_mode
193194
}));
195+
Object[] arr = convertToObjectArray(PythonOptions.getExecutableList(context));
196+
PList executableList = PythonObjectFactory.getUncached().createList(arr);
197+
mod.setAttribute("executable_list", executableList);
198+
}
199+
200+
private static Object[] convertToObjectArray(String[] arr) {
201+
Object[] objectArr = new Object[arr.length];
202+
System.arraycopy(arr, 0, objectArr, 0, arr.length);
203+
return objectArr;
194204
}
195205

196206
@Builtin(name = "cache_module_code", minNumOfPositionalArgs = 3)

graalpython/lib-python/3/venv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def create_if_needed(d):
139139
with open(script, "w") as f:
140140
if sys.platform != "win32":
141141
f.write("#!/bin/sh\n")
142-
f.write(sys.executable)
142+
f.write(" ".join(__graalpython__.executable_list))
143143
f.write(" --experimental-options --python.CoreHome='%s' --python.StdLibHome='%s' --python.SysPrefix='%s' --python.SysBasePrefix='%s' --python.Executable='%s' --python.CAPI='%s'" % (
144144
__graalpython__.core_home,
145145
__graalpython__.stdlib_home,

0 commit comments

Comments
 (0)