Skip to content

Commit eb801a0

Browse files
committed
Adapt getting executable to the new thin launcher
1 parent d8aa2ce commit eb801a0

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public static void main(String[] args) {
7373

7474
private static final String LANGUAGE_ID = "python";
7575

76-
// provided by GraalVM bash launchers, ignored in native image mode
77-
protected static final String J_BASH_LAUNCHER_EXEC_NAME = System.getProperty("org.graalvm.launcher.executablename");
76+
// provided by GraalVM thin launcher
77+
protected static final String J_BASH_LAUNCHER_EXEC_PROPERTY_NAME = "org.graalvm.launcher.executablename";
7878

7979
private static long startupWallClockTime = -1;
8080
private static long startupNanoTime = -1;
@@ -101,6 +101,7 @@ public static void main(String[] args) {
101101
private boolean dontWriteBytecode = false;
102102
private String warnOptions = null;
103103
private String checkHashPycsMode = "default";
104+
private String execName;
104105

105106
boolean useASTInterpreter = false;
106107

@@ -404,18 +405,16 @@ private static void print(String string) {
404405
System.err.println(string);
405406
}
406407

407-
private static String getLauncherExecName() {
408-
if (ImageInfo.inImageCode()) {
409-
String binPathName = null;
410-
if (ProcessProperties.getArgumentVectorBlockSize() > 0) {
411-
binPathName = calculateProgramFullPath(ProcessProperties.getArgumentVectorProgramName());
412-
}
413-
if (binPathName != null) {
414-
return binPathName;
415-
}
416-
return ProcessProperties.getExecutableName();
408+
protected String getLauncherExecName() {
409+
if (execName != null) {
410+
return execName;
411+
}
412+
execName = getProgramName();
413+
if (execName == null) {
414+
return null;
417415
}
418-
return GraalPythonMain.J_BASH_LAUNCHER_EXEC_NAME;
416+
execName = calculateProgramFullPath(execName);
417+
return execName;
419418
}
420419

421420
/**

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,21 @@ public Object doIt(PFunction func,
499499
}
500500
}
501501

502+
/*
503+
* Internal check used in tests only to check that we are running through managed launcher.
504+
*/
505+
@Builtin(name = "is_managed_launcher")
506+
@TypeSystemReference(PythonArithmeticTypes.class)
507+
@GenerateNodeFactory
508+
public abstract static class IsManagedLauncher extends PythonBuiltinNode {
509+
@Specialization
510+
@TruffleBoundary
511+
protected boolean isManaged() {
512+
// The best approximation for now
513+
return !getContext().getEnv().isNativeAccessAllowed() && getContext().getOption(PythonOptions.RunViaLauncher);
514+
}
515+
}
516+
502517
@Builtin(name = "get_toolchain_tool_path", minNumOfPositionalArgs = 1)
503518
@TypeSystemReference(PythonArithmeticTypes.class)
504519
@GenerateNodeFactory

0 commit comments

Comments
 (0)