Skip to content

Commit f8bd1bb

Browse files
committed
[GR-27539] Allow to specify main class.
PullRequest: graalpython/1410
2 parents 6e4c263 + 580cab5 commit f8bd1bb

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,15 @@
6262

6363
public class GraalPythonMain extends AbstractLanguageLauncher {
6464
public static void main(String[] args) {
65-
if (GraalPythonMain.startupNanoTime == -1) {
66-
GraalPythonMain.startupNanoTime = System.nanoTime();
67-
}
68-
if (GraalPythonMain.startupWallClockTime == -1) {
69-
GraalPythonMain.startupWallClockTime = System.currentTimeMillis();
70-
}
65+
GraalPythonMain.setStartupTime();
7166
new GraalPythonMain().launch(args);
7267
}
7368

7469
private static final String LANGUAGE_ID = "python";
7570
private static final String MIME_TYPE = "text/x-python";
7671

7772
// provided by GraalVM bash launchers, ignored in native image mode
78-
private static final String BASH_LAUNCHER_EXEC_NAME = System.getProperty("org.graalvm.launcher.executablename");
73+
protected static final String BASH_LAUNCHER_EXEC_NAME = System.getProperty("org.graalvm.launcher.executablename");
7974

8075
private static long startupWallClockTime = -1;
8176
private static long startupNanoTime = -1;
@@ -103,6 +98,15 @@ public static void main(String[] args) {
10398
private String warnOptions = null;
10499
private String checkHashPycsMode = "default";
105100

101+
protected static void setStartupTime() {
102+
if (GraalPythonMain.startupNanoTime == -1) {
103+
GraalPythonMain.startupNanoTime = System.nanoTime();
104+
}
105+
if (GraalPythonMain.startupWallClockTime == -1) {
106+
GraalPythonMain.startupWallClockTime = System.currentTimeMillis();
107+
}
108+
}
109+
106110
@Override
107111
protected List<String> preprocessArguments(List<String> givenArgs, Map<String, String> polyglotOptions) {
108112
ArrayList<String> unrecognized = new ArrayList<>();

mx.graalpython/mx_graalpython.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
SUITE_COMPILER = mx.suite("compiler", fatalIfMissing=False)
7373
SUITE_SULONG = mx.suite("sulong")
7474

75+
GRAALPYTHON_MAIN_CLASS = "com.oracle.graal.python.shell.GraalPythonMain"
76+
7577

7678
if PY3:
7779
raw_input = input # pylint: disable=redefined-builtin;
@@ -128,7 +130,7 @@ def python(args, **kwargs):
128130
do_run_python(args, **kwargs)
129131

130132

131-
def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None, cp_prefix=None, cp_suffix=None, **kwargs):
133+
def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None, cp_prefix=None, cp_suffix=None, main_class=GRAALPYTHON_MAIN_CLASS, **kwargs):
132134
if not any(arg.startswith("--python.CAPI") for arg in args):
133135
capi_home = _get_capi_home()
134136
args.insert(0, "--experimental-options")
@@ -177,7 +179,7 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None
177179
if extra_vm_args:
178180
vm_args += extra_vm_args
179181

180-
vm_args.append("com.oracle.graal.python.shell.GraalPythonMain")
182+
vm_args.append(main_class)
181183
return mx.run_java(vm_args + graalpython_args, jdk=jdk, env=env, **kwargs)
182184

183185

@@ -1403,6 +1405,7 @@ def verify_ci(dest_suite, common_ci_dir="ci_common", args=None, ext=('.jsonnet',
14031405
suite=SUITE,
14041406
name='Graal.Python',
14051407
short_name='pyn',
1408+
installable_id='graalpython',
14061409
dir_name='python',
14071410
standalone_dir_name='graalpython-<version>-<graalvm_os>-<arch>',
14081411
license_files=[],
@@ -1425,7 +1428,7 @@ def verify_ci(dest_suite, common_ci_dir="ci_common", args=None, ext=('.jsonnet',
14251428
mx_sdk.LanguageLauncherConfig(
14261429
destination='bin/<exe:graalpython>',
14271430
jar_distributions=['graalpython:GRAALPYTHON-LAUNCHER'],
1428-
main_class='com.oracle.graal.python.shell.GraalPythonMain',
1431+
main_class=GRAALPYTHON_MAIN_CLASS,
14291432
build_args=[
14301433
'-H:+TruffleCheckBlackListedMethods',
14311434
'-H:+DetectUserDirectoriesInImageHeap',
@@ -1434,6 +1437,7 @@ def verify_ci(dest_suite, common_ci_dir="ci_common", args=None, ext=('.jsonnet',
14341437
language='python',
14351438
)
14361439
],
1440+
priority=5
14371441
))
14381442

14391443

0 commit comments

Comments
 (0)