37
37
import mx_urlrewrites
38
38
from mx_gate import Task
39
39
from mx_graalpython_bench_param import PATH_MESO , BENCHMARKS
40
- from mx_graalpython_benchmark import PythonBenchmarkSuite
40
+ from mx_graalpython_benchmark import PythonBenchmarkSuite , python_vm_registry , CPythonVm , PyPyVm , GraalPythonVm , \
41
+ CONFIGURATION_DEFAULT
41
42
from mx_unittest import unittest
42
43
43
- _suite = mx .suite ('graalpython' )
44
- _mx_graal = mx .suite ("compiler" , fatalIfMissing = False )
45
- _sulong = mx .suite ("sulong" )
44
+ SUITE = mx .suite ('graalpython' )
45
+ SUITE_COMPILER = mx .suite ("compiler" , fatalIfMissing = False )
46
+ SUITE_SULONG = mx .suite ("sulong" )
46
47
47
48
48
49
def _get_core_home ():
49
- return os .path .join (_suite .dir , "graalpython" , "lib-graalpython" )
50
+ return os .path .join (SUITE .dir , "graalpython" , "lib-graalpython" )
50
51
51
52
52
53
def _get_stdlib_home ():
53
- return os .path .join (_suite .dir , "graalpython" , "lib-python" , "3" )
54
+ return os .path .join (SUITE .dir , "graalpython" , "lib-python" , "3" )
54
55
55
56
56
57
def _get_svm_binary ():
57
- return os .path .join (_suite .dir , "graalpython-svm" )
58
+ return os .path .join (SUITE .dir , "graalpython-svm" )
58
59
59
60
60
61
def __get_svm_binary_from_graalvm ():
@@ -131,7 +132,7 @@ def _extract_graalpython_internal_options(args):
131
132
elif arg == '-force-long' :
132
133
internal += ["-Dcom.oracle.graal.python.forceLongType=true" ] # false
133
134
134
- elif arg == '-debug-perf' and _mx_graal :
135
+ elif arg == '-debug-perf' and SUITE_COMPILER :
135
136
# internal += ['-Dgraal.InliningDepthError=500']
136
137
# internal += ['-Dgraal.EscapeAnalysisIterations=3']
137
138
# internal += ['-XX:JVMCINMethodSizeLimit=1000000']
@@ -149,7 +150,7 @@ def _extract_graalpython_internal_options(args):
149
150
# internal += ['-Dgraal.MaximumLoopExplosionCount=1000']
150
151
# internal += ['-Dgraal.TruffleCompilationThreshold=100000']
151
152
152
- elif arg == '-compile-truffle-immediately' and _mx_graal :
153
+ elif arg == '-compile-truffle-immediately' and SUITE_COMPILER :
153
154
internal += ['-Dgraal.TruffleCompileImmediately=true' ]
154
155
internal += ['-Dgraal.TruffleCompilationExceptionsAreThrown=true' ]
155
156
@@ -160,7 +161,7 @@ def _extract_graalpython_internal_options(args):
160
161
161
162
162
163
def check_vm (vm_warning = True , must_be_jvmci = False ):
163
- if not _mx_graal :
164
+ if not SUITE_COMPILER :
164
165
if must_be_jvmci :
165
166
print '** Error ** : graal compiler was not found!'
166
167
sys .exit (1 )
@@ -170,7 +171,7 @@ def check_vm(vm_warning=True, must_be_jvmci=False):
170
171
171
172
172
173
def get_jdk ():
173
- if _mx_graal :
174
+ if SUITE_COMPILER :
174
175
tag = 'jvmci'
175
176
else :
176
177
tag = None
@@ -201,7 +202,7 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, **kwargs):
201
202
if '--python.WithJavaStacktrace' not in graalpython_args :
202
203
graalpython_args .insert (0 , '--python.WithJavaStacktrace' )
203
204
204
- if _sulong :
205
+ if SUITE_SULONG :
205
206
dists .append ('SULONG' )
206
207
if mx .suite ("sulong-managed" , fatalIfMissing = False ):
207
208
dists .append ('SULONG_MANAGED' )
@@ -217,9 +218,9 @@ def _is_user(user, home=None):
217
218
return os .environ .get ("USER" ) == user
218
219
219
220
if _is_user ("tim" , "MAGLEV_HOME" ) or _is_user ("cbasca" ) or _is_user ("fa" ):
220
- _suite .import_suite ("tools" , version = None , urlinfos = None , in_subdir = True )
221
+ SUITE .import_suite ("tools" , version = None , urlinfos = None , in_subdir = True )
221
222
dists .append ('CHROMEINSPECTOR' )
222
- if _sulong :
223
+ if SUITE_SULONG :
223
224
vm_args .append ("-Dpolyglot.llvm.enableLVI=true" )
224
225
225
226
vm_args += mx .get_runtime_jvm_args (dists , jdk = jdk )
@@ -254,7 +255,7 @@ def nativebuild(args):
254
255
255
256
256
257
def nativeclean (args ):
257
- mx .run (['find' , _suite .dir , '-name' , '*.bc' , '-delete' ])
258
+ mx .run (['find' , SUITE .dir , '-name' , '*.bc' , '-delete' ])
258
259
259
260
260
261
def python3_unittests (args ):
@@ -291,17 +292,17 @@ def python_gate(args):
291
292
292
293
293
294
def find_jdt ():
294
- pardir = os .path .abspath (os .path .join (_suite .dir , ".." ))
295
- for f in [os .path .join (_suite .dir , f ) for f in os .listdir (_suite .dir )] + [os .path .join (pardir , f ) for f in os .listdir (pardir )]:
295
+ pardir = os .path .abspath (os .path .join (SUITE .dir , ".." ))
296
+ for f in [os .path .join (SUITE .dir , f ) for f in os .listdir (SUITE .dir )] + [os .path .join (pardir , f ) for f in os .listdir (pardir )]:
296
297
if os .path .basename (f ).startswith ("ecj-" ) and os .path .basename (f ).endswith (".jar" ):
297
298
mx .log ("Automatically choosing %s for JDT" % f )
298
299
os .environ ["JDT" ] = f
299
300
return
300
301
301
302
302
303
def find_eclipse ():
303
- pardir = os .path .abspath (os .path .join (_suite .dir , ".." ))
304
- for f in [os .path .join (_suite .dir , f ) for f in os .listdir (_suite .dir )] + [os .path .join (pardir , f ) for f in os .listdir (pardir )]:
304
+ pardir = os .path .abspath (os .path .join (SUITE .dir , ".." ))
305
+ for f in [os .path .join (SUITE .dir , f ) for f in os .listdir (SUITE .dir )] + [os .path .join (pardir , f ) for f in os .listdir (pardir )]:
305
306
if os .path .basename (f ) == "eclipse" and os .path .isdir (f ):
306
307
mx .log ("Automatically choosing %s for Eclipse" % f )
307
308
eclipse_exe = os .path .join (f , "eclipse" )
@@ -351,7 +352,7 @@ def gate_unittests(args=[], subdir=""):
351
352
352
353
def run_python_unittests (python_binary , args = [], aot_compatible = True , exclude = []):
353
354
# tests root directory
354
- tests_folder = os .path .join (_suite .dir , "graalpython" , "com.oracle.graal.python.test" , "src" , "tests" )
355
+ tests_folder = os .path .join (SUITE .dir , "graalpython" , "com.oracle.graal.python.test" , "src" , "tests" )
355
356
356
357
# list of excluded tests
357
358
if aot_compatible :
@@ -377,7 +378,7 @@ def is_included(path):
377
378
except OSError :
378
379
pass
379
380
380
- args += [os .path .join (_suite .dir , "graalpython" , "com.oracle.graal.python.test" , "src" , "graalpytest.py" ), "-v" ]
381
+ args += [os .path .join (SUITE .dir , "graalpython" , "com.oracle.graal.python.test" , "src" , "graalpytest.py" ), "-v" ]
381
382
args += testfiles
382
383
return mx .run ([python_binary ] + args , nonZeroIsFatal = True )
383
384
@@ -414,15 +415,15 @@ def graalpython_gate_runner(args, tasks):
414
415
if not os .path .exists (svm_image_name ):
415
416
svm_image_name = python_svm (["-h" ])
416
417
llvm_home = mx_subst .path_substitutions .substitute ('--native.Dllvm.home=<path:SULONG_LIBS>' )
417
- args = ["--python.CoreHome=%s" % os .path .join (_suite .dir , "graalpython" , "lib-graalpython" ),
418
- "--python.StdLibHome=%s" % os .path .join (_suite .dir , "graalpython" , "lib-python/3" ),
418
+ args = ["--python.CoreHome=%s" % os .path .join (SUITE .dir , "graalpython" , "lib-graalpython" ),
419
+ "--python.StdLibHome=%s" % os .path .join (SUITE .dir , "graalpython" , "lib-python/3" ),
419
420
llvm_home ]
420
421
run_python_unittests (svm_image_name , args )
421
422
422
423
with Task ('GraalPython apptests' , tasks , tags = [GraalPythonTags .apptests ]) as task :
423
424
if task :
424
425
apprepo = os .environ ["GRAALPYTHON_APPTESTS_REPO_URL" ]
425
- _apptest_suite = _suite .import_suite (
426
+ _apptest_suite = SUITE .import_suite (
426
427
"graalpython-apptests" ,
427
428
version = "fe1458e3af707f5996f192aedc7b76585501e8ba" ,
428
429
urlinfos = [mx .SuiteImportURLInfo (mx_urlrewrites .rewriteurl (apprepo ), "git" , mx .vc_system ("git" ))]
@@ -453,13 +454,13 @@ def graalpython_gate_runner(args, tasks):
453
454
if success not in out .data :
454
455
mx .abort ('Output from generated SVM image "' + svm_image + '" did not match success pattern:\n ' + success )
455
456
llvm_home = mx_subst .path_substitutions .substitute ('--native.Dllvm.home=<path:SULONG_LIBS>' )
456
- args = ["--python.CoreHome=%s" % os .path .join (_suite .dir , "graalpython" , "lib-graalpython" ),
457
- "--python.StdLibHome=%s" % os .path .join (_suite .dir , "graalpython" , "lib-python/3" ),
457
+ args = ["--python.CoreHome=%s" % os .path .join (SUITE .dir , "graalpython" , "lib-graalpython" ),
458
+ "--python.StdLibHome=%s" % os .path .join (SUITE .dir , "graalpython" , "lib-python/3" ),
458
459
llvm_home ]
459
460
run_python_unittests (svm_image , args )
460
461
461
462
462
- mx_gate .add_gate_runner (_suite , graalpython_gate_runner )
463
+ mx_gate .add_gate_runner (SUITE , graalpython_gate_runner )
463
464
464
465
465
466
def run_shared_lib_test (args = None ):
@@ -593,7 +594,7 @@ def run_shared_lib_test(args=None):
593
594
}
594
595
""" )
595
596
os .close (fd )
596
- progname = os .path .join (_suite .dir , "graalpython-embedded-tool" )
597
+ progname = os .path .join (SUITE .dir , "graalpython-embedded-tool" )
597
598
mx .log ("" .join (["Running " , "'clang" , "-I%s" % svm_lib_path , "-L%s" % svm_lib_path , name , "-o" , progname , "-lpolyglot" ]))
598
599
mx .run (["clang" , "-I%s" % svm_lib_path , "-L%s" % svm_lib_path , name , "-o%s" % progname , "-lpolyglot" ], nonZeroIsFatal = True )
599
600
mx .log ("Running " + progname + " with LD_LIBRARY_PATH " + svm_lib_path )
@@ -650,7 +651,7 @@ def getResults(self):
650
651
def deploy_binary_if_master (args ):
651
652
"""if the active branch is 'master', deploy binaries for the primary suite to remote maven repository."""
652
653
master_branch = 'master'
653
- active_branch = mx .VC .get_vc (_suite .dir ).active_branch (_suite .dir )
654
+ active_branch = mx .VC .get_vc (SUITE .dir ).active_branch (SUITE .dir )
654
655
if active_branch == master_branch :
655
656
if sys .platform == "darwin" :
656
657
args .insert (0 , "--platform-dependent" )
@@ -684,8 +685,8 @@ def delete_self_if_testdownstream(args):
684
685
"""
685
686
A helper for downstream testing with binary dependencies
686
687
"""
687
- if str (_suite .dir ).endswith ("testdownstream/graalpython" ):
688
- shutil .rmtree (_suite .dir , ignore_errors = True )
688
+ if str (SUITE .dir ).endswith ("testdownstream/graalpython" ):
689
+ shutil .rmtree (SUITE .dir , ignore_errors = True )
689
690
690
691
691
692
def update_import (name , rev = "origin/master" , callback = None ):
@@ -718,11 +719,11 @@ def update_import_cmd(args):
718
719
if name == "sulong" :
719
720
join = os .path .join
720
721
callback = lambda : shutil .copy (
721
- join (_sulong .dir , "include" , "truffle.h" ),
722
- join (_suite .dir , "graalpython" , "com.oracle.graal.python.cext" , "include" , "truffle.h" )
722
+ join (SUITE_SULONG .dir , "include" , "truffle.h" ),
723
+ join (SUITE .dir , "graalpython" , "com.oracle.graal.python.cext" , "include" , "truffle.h" )
723
724
) and shutil .copy (
724
725
join (mx .dependency ("SULONG_LIBS" ).output , "polyglot.h" ),
725
- join (_suite .dir , "graalpython" , "com.oracle.graal.python.cext" , "include" , "polyglot.h" )
726
+ join (SUITE .dir , "graalpython" , "com.oracle.graal.python.cext" , "include" , "polyglot.h" )
726
727
)
727
728
# make sure that sulong and regex are the same version
728
729
if name == "regex" :
@@ -819,11 +820,11 @@ def import_python_sources(args):
819
820
files = [line .split ("," )[0 ] for line in f .read ().split ("\n " ) if len (line .split ("," )) > 1 and line .split ("," )[1 ] == "python.copyright" ]
820
821
821
822
# move to orphaned branch with sources
822
- if _suite .vc .isDirty (_suite .dir ):
823
+ if SUITE .vc .isDirty (SUITE .dir ):
823
824
mx .abort ("Working dir must be clean" )
824
- tip = _suite .vc .tip (_suite .dir ).strip ()
825
- _suite .vc .git_command (_suite .dir , ["checkout" , "python-import" ])
826
- _suite .vc .git_command (_suite .dir , ["clean" , "-fdx" ])
825
+ tip = SUITE .vc .tip (SUITE .dir ).strip ()
826
+ SUITE .vc .git_command (SUITE .dir , ["checkout" , "python-import" ])
827
+ SUITE .vc .git_command (SUITE .dir , ["clean" , "-fdx" ])
827
828
shutil .rmtree ("graalpython" )
828
829
829
830
for inlined_file in files :
@@ -849,27 +850,18 @@ def import_python_sources(args):
849
850
mx .warn ("Could not update %s - original file not found" % inlined_file )
850
851
851
852
# re-copy lib-python
852
- libdir = os .path .join (_suite .dir , "graalpython/lib-python/3" )
853
+ libdir = os .path .join (SUITE .dir , "graalpython/lib-python/3" )
853
854
shutil .copytree (os .path .join (pypy_sources , "lib-python" , "3" ), libdir )
854
855
855
856
# commit and check back
856
- _suite .vc .git_command (_suite .dir , ["add" , "." ])
857
+ SUITE .vc .git_command (SUITE .dir , ["add" , "." ])
857
858
raw_input ("Check that the updated files look as intended, then press RETURN..." )
858
- _suite .vc .commit (_suite .dir , "Update Python inlined files: %s" % import_version )
859
+ SUITE .vc .commit (SUITE .dir , "Update Python inlined files: %s" % import_version )
859
860
answer = raw_input ("Should we push python-import (y/N)? " )
860
861
if answer and answer in "Yy" :
861
- _suite .vc .git_command (_suite .dir , ["push" , "origin" , "python-import:python-import" ])
862
- _suite .vc .update (_suite .dir , rev = tip )
863
- _suite .vc .git_command (_suite .dir , ["merge" , "python-import" ])
864
-
865
-
866
- # ----------------------------------------------------------------------------------------------------------------------
867
- #
868
- # add the defined python benchmark suites
869
- #
870
- # ----------------------------------------------------------------------------------------------------------------------
871
- for py_bench_suite in PythonBenchmarkSuite .get_benchmark_suites (BENCHMARKS ):
872
- mx_benchmark .add_bm_suite (py_bench_suite )
862
+ SUITE .vc .git_command (SUITE .dir , ["push" , "origin" , "python-import:python-import" ])
863
+ SUITE .vc .update (SUITE .dir , rev = tip )
864
+ SUITE .vc .git_command (SUITE .dir , ["merge" , "python-import" ])
873
865
874
866
875
867
# ----------------------------------------------------------------------------------------------------------------------
@@ -878,7 +870,7 @@ def import_python_sources(args):
878
870
#
879
871
# ----------------------------------------------------------------------------------------------------------------------
880
872
mx_sdk .register_graalvm_component (mx_sdk .GraalVmLanguage (
881
- suite = _suite ,
873
+ suite = SUITE ,
882
874
name = 'Graal.Python' ,
883
875
short_name = 'pyn' ,
884
876
dir_name = 'python' ,
@@ -911,18 +903,41 @@ def import_python_sources(args):
911
903
#
912
904
# ----------------------------------------------------------------------------------------------------------------------
913
905
if not os .getenv ("GRAAL_PYTHONHOME" ):
914
- home = os .path .join (_suite .dir , "graalpython" )
906
+ home = os .path .join (SUITE .dir , "graalpython" )
915
907
if not os .path .exists (home ):
916
- home = [d for d in _suite .dists if d .name == "GRAALPYTHON_GRAALVM_SUPPORT" ][0 ].output
908
+ home = [d for d in SUITE .dists if d .name == "GRAALPYTHON_GRAALVM_SUPPORT" ][0 ].output
917
909
os .environ ["GRAAL_PYTHONHOME" ] = home
918
910
919
911
912
+ # ----------------------------------------------------------------------------------------------------------------------
913
+ #
914
+ # post init
915
+ #
916
+ # ----------------------------------------------------------------------------------------------------------------------
917
+
918
+ def _register_vms (namespace ):
919
+ python_vm_registry .add_vm (CPythonVm (CONFIGURATION_DEFAULT ), SUITE )
920
+ python_vm_registry .add_vm (PyPyVm (CONFIGURATION_DEFAULT ), SUITE )
921
+ python_vm_registry .add_vm (GraalPythonVm (config_name = CONFIGURATION_DEFAULT ), SUITE , 10 )
922
+
923
+
924
+ def _register_bench_suites (namespace ):
925
+ for py_bench_suite in PythonBenchmarkSuite .get_benchmark_suites (BENCHMARKS ):
926
+ mx_benchmark .add_bm_suite (py_bench_suite )
927
+
928
+
929
+ def mx_post_parse_cmd_line (namespace ):
930
+ # all projects are now available at this time
931
+ _register_vms (namespace )
932
+ _register_bench_suites (namespace )
933
+
934
+
920
935
# ----------------------------------------------------------------------------------------------------------------------
921
936
#
922
937
# register the suite commands (if any)
923
938
#
924
939
# ----------------------------------------------------------------------------------------------------------------------
925
- mx .update_commands (_suite , {
940
+ mx .update_commands (SUITE , {
926
941
'python' : [python , '[Python args|@VM options]' ],
927
942
'python3' : [python , '[Python args|@VM options]' ],
928
943
'deploy-binary-if-master' : [deploy_binary_if_master , '' ],
0 commit comments