@@ -820,17 +820,86 @@ def _join_bin(home, name):
820
820
return os .path .join (home , "bin" , name )
821
821
822
822
823
- def graalpy_standalone ():
823
+ def _graalpy_launcher (managed = False ):
824
+ name = 'graalpy-managed' if managed else 'graalpy'
825
+ return f"{ name } .exe" if WIN32 else name
826
+
827
+
828
+ def graalpy_standalone_home (standalone_type , enterprise = False ):
829
+ assert standalone_type in ['native' , 'jvm' ]
824
830
jdk_version = mx .get_jdk ().javaCompliance # Not our "get_jdk", because we do not want the jvmci tag.
825
- mx_args = ['-p' , os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' ), '--env' , 'ce-python' ]
826
- if not DISABLE_REBUILD :
827
- mx .run_mx (mx_args + ["build" , "--dep" , f"PYTHON_JAVA_STANDALONE_SVM_JAVA{ jdk_version } " ])
828
- out = mx .OutputCapture ()
829
- mx .run_mx (mx_args + ["standalone-home" , "--type" , "jvm" , "python" ], out = out )
830
- python_home = out .data .splitlines ()[- 1 ].strip ()
831
+ python_home = os .environ .get ("GRAALPY_HOME" , None )
832
+ if python_home and "*" in python_home :
833
+ python_home = os .path .abspath (glob .glob (python_home )[0 ])
834
+ mx .log ("Using GraalPy standalone from GRAALPY_HOME: " + python_home )
835
+ # Try to verify that we're getting what we expect:
836
+ has_java = os .path .exists (os .path .join (python_home , 'jvm' , 'bin' , 'java' ))
837
+ if has_java != (standalone_type == 'jvm' ):
838
+ mx .abort (f"GRAALPY_HOME is not compatible with the requested distribution type.\n "
839
+ f"jvm/bin/java exists?: { has_java } , requested type={ standalone_type } ." )
840
+
841
+ line = ''
842
+ with open (os .path .join (python_home , 'release' ), 'r' ) as f :
843
+ while 'JAVA_VERSION=' not in line :
844
+ line = f .readline ()
845
+ if 'JAVA_VERSION=' not in line :
846
+ mx .abort (f"GRAALPY_HOME does not contain 'release' file. Cannot check Java version." )
847
+ actual_jdk_version = line .strip ('JAVA_VERSION=' ).strip (' "\n \r ' )
848
+ if actual_jdk_version != jdk_version :
849
+ mx .abort (f"GRAALPY_HOME is not compatible with the requested JDK version.\n "
850
+ f"actual version: '{ actual_jdk_version } ', version string: { line } , requested version: { jdk_version } ." )
851
+
852
+ launcher = os .path .join (python_home , 'bin' , _graalpy_launcher (enterprise ))
853
+ out = mx .OutputCapture ()
854
+ import_managed_status = mx .run ([launcher , "-c" , "import __graalpython_enterprise__" ], nonZeroIsFatal = False , out = out , err = out )
855
+ if enterprise != (import_managed_status == 0 ):
856
+ mx .abort (f"GRAALPY_HOME is not compatible with requested distribution kind ({ import_managed_status = } , { enterprise = } , { out = } )." )
857
+ else :
858
+ env_file = 'ce-python'
859
+ vm_suite_path = os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' )
860
+ svm_distr = ''
861
+ if enterprise :
862
+ env_file = 'ee-python'
863
+ vm_suite_path = os .path .join (mx .suite ('graal-enterprise' ).dir , '..' , 'vm-enterprise' )
864
+ svm_distr = '_SVMEE'
865
+ mx_args = ['-p' , vm_suite_path , '--env' , env_file ]
866
+ if not DISABLE_REBUILD :
867
+ dep_type = 'JAVA' if standalone_type == 'jvm' else 'NATIVE'
868
+ mx .run_mx (mx_args + ["build" , "--dep" , f"PYTHON_{ dep_type } _STANDALONE_SVM{ svm_distr } _JAVA{ jdk_version } " ])
869
+ out = mx .OutputCapture ()
870
+ mx .run_mx (mx_args + ["standalone-home" , "--type" , standalone_type , "python" ], out = out )
871
+ python_home = out .data .splitlines ()[- 1 ].strip ()
831
872
return python_home
832
873
833
874
875
+ def graalpy_standalone (standalone_type , managed = False ):
876
+ assert standalone_type in ['native' , 'jvm' ]
877
+ if standalone_type == 'native' and mx_gate .get_jacoco_agent_args ():
878
+ return graalpy_standalone ('jvm' )
879
+
880
+ launcher = os .path .join (graalpy_standalone_home (standalone_type , managed ), 'bin' , _graalpy_launcher (managed ))
881
+ return make_coverage_launcher_if_needed (launcher )
882
+
883
+ def graalpy_standalone_jvm ():
884
+ return graalpy_standalone ('jvm' )
885
+
886
+
887
+ def graalpy_standalone_native ():
888
+ return graalpy_standalone ('native' )
889
+
890
+
891
+ def graalpy_standalone_jvm_managed ():
892
+ return graalpy_standalone ('jvm' , managed = True )
893
+
894
+
895
+ def graalpy_standalone_jvm_enterprise ():
896
+ return os .path .join (graalpy_standalone_home ('jvm' , enterprise = True ), 'bin' , _graalpy_launcher (managed = False ))
897
+
898
+
899
+ def graalpy_standalone_native_managed ():
900
+ return graalpy_standalone ('native' , managed = True )
901
+
902
+
834
903
def graalvm_jdk ():
835
904
jdk_version = mx .get_jdk ().javaCompliance # Not our "get_jdk", because we do not want the jvmci tag.
836
905
mx_args = ['-p' , os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' ), '--env' , 'ce' ]
@@ -870,8 +939,12 @@ def deploy_local_maven_repo():
870
939
871
940
def python_gvm (_ = None ):
872
941
home = _graalvm_home (envfile = "graalpython-bash-launcher" )
873
- launcher = _join_bin (home , "graalpy" )
942
+ launcher = make_coverage_launcher_if_needed (_join_bin (home , "graalpy" ))
943
+ mx .log (launcher )
944
+ return launcher
945
+
874
946
947
+ def make_coverage_launcher_if_needed (launcher ):
875
948
if mx_gate .get_jacoco_agent_args ():
876
949
# patch our launchers created under jacoco to also run with jacoco.
877
950
# do not use is_collecting_coverage() here, we only want to patch when
@@ -882,6 +955,7 @@ def graalvm_vm_arg(java_arg):
882
955
java_arg = f .read ()
883
956
assert java_arg [0 ] == "-" , java_arg
884
957
return shlex .quote (f'--vm.{ java_arg [1 :]} ' )
958
+
885
959
agent_args = ' ' .join (graalvm_vm_arg (arg ) for arg in mx_gate .get_jacoco_agent_args () or [])
886
960
887
961
# We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher
@@ -894,23 +968,7 @@ def graalvm_vm_arg(java_arg):
894
968
f .write (f'{ original_launcher } --jvm { exe_arg } { agent_args } "$@"\n ' )
895
969
os .chmod (bash_launcher , 0o775 )
896
970
mx .log (f"Replaced { launcher } with { bash_launcher } to collect coverage" )
897
- return bash_launcher
898
-
899
- mx .log (launcher )
900
- return launcher
901
-
902
-
903
- def python_managed_gvm (_ = None ):
904
- home = _graalvm_home (envfile = "graalpython-managed-bash-launcher" )
905
- launcher = _join_bin (home , "graalpy-managed" )
906
- mx .log (launcher )
907
- return launcher
908
-
909
-
910
- def python_enterprise_gvm (_ = None ):
911
- home = _graalvm_home (envfile = "graalpython-managed-bash-launcher" )
912
- launcher = _join_bin (home , "graalpy" )
913
- mx .log (launcher )
971
+ launcher = bash_launcher
914
972
return launcher
915
973
916
974
@@ -923,13 +981,6 @@ def python_svm(_=None):
923
981
return launcher
924
982
925
983
926
- def python_managed_svm ():
927
- home = _graalvm_home (envfile = "graalpython-managed-launcher" )
928
- launcher = _join_bin (home , "graalpy-managed" )
929
- mx .log (launcher )
930
- return launcher
931
-
932
-
933
984
def native_image (args ):
934
985
mx .run_mx ([
935
986
"-p" , os .path .join (mx .suite ("truffle" ).dir , ".." , "substratevm" ),
@@ -946,14 +997,6 @@ def native_image(args):
946
997
])
947
998
948
999
949
- def python_so ():
950
- return _graalvm_home (envfile = "graalpython-libpolyglot" )
951
-
952
-
953
- def python_managed_so ():
954
- return _graalvm_home (envfile = "graalpython-managed-libpolyglot" )
955
-
956
-
957
1000
def _graalpytest_driver ():
958
1001
return os .path .join (SUITE .dir , "graalpython" , "com.oracle.graal.python.test" , "src" , "graalpytest.py" )
959
1002
@@ -1399,7 +1442,7 @@ def graalpython_gate_runner(args, tasks):
1399
1442
if not WIN32 :
1400
1443
mx .run (["env" ])
1401
1444
run_python_unittests (
1402
- python_gvm (),
1445
+ graalpy_standalone_jvm (),
1403
1446
javaAsserts = True ,
1404
1447
exclude = excluded_tests ,
1405
1448
nonZeroIsFatal = nonZeroIsFatal ,
@@ -1419,39 +1462,35 @@ def graalpython_gate_runner(args, tasks):
1419
1462
1420
1463
with Task ('GraalPython sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_sandboxed ]) as task :
1421
1464
if task :
1422
- run_python_unittests (python_managed_gvm (), javaAsserts = True , exclude = excluded_tests , report = report ())
1465
+ run_python_unittests (graalpy_standalone_native_managed (), javaAsserts = True , exclude = excluded_tests , report = report ())
1423
1466
1424
1467
with Task ('GraalPython multi-context unittests' , tasks , tags = [GraalPythonTags .unittest_multi ]) as task :
1425
1468
if task :
1426
- run_python_unittests (python_gvm (), args = ["-multi-context" ], javaAsserts = True , exclude = excluded_tests , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1469
+ run_python_unittests (graalpy_standalone_jvm (), args = ["-multi-context" ], javaAsserts = True , exclude = excluded_tests , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1427
1470
1428
1471
with Task ('GraalPython Jython emulation tests' , tasks , tags = [GraalPythonTags .unittest_jython ]) as task :
1429
1472
if task :
1430
- run_python_unittests (python_gvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ], javaAsserts = True , report = report (), nonZeroIsFatal = nonZeroIsFatal )
1431
-
1432
- with Task ('GraalPython ginstall' , tasks , tags = [GraalPythonTags .ginstall ], report = True ) as task :
1433
- if task :
1434
- run_ginstall (python_gvm (), args = ["--quiet" ])
1473
+ run_python_unittests (graalpy_standalone_jvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ], javaAsserts = True , report = report (), nonZeroIsFatal = nonZeroIsFatal )
1435
1474
1436
1475
with Task ('GraalPython HPy tests' , tasks , tags = [GraalPythonTags .unittest_hpy ]) as task :
1437
1476
if task :
1438
- run_hpy_unittests (python_svm (), nonZeroIsFatal = nonZeroIsFatal , report = report ())
1477
+ run_hpy_unittests (graalpy_standalone_native (), nonZeroIsFatal = nonZeroIsFatal , report = report ())
1439
1478
1440
1479
with Task ('GraalPython HPy sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_hpy_sandboxed ]) as task :
1441
1480
if task :
1442
- run_hpy_unittests (python_managed_svm (), include_native = False , report = report ())
1481
+ run_hpy_unittests (graalpy_standalone_native_managed (), include_native = False , report = report ())
1443
1482
1444
1483
with Task ('GraalPython posix module tests' , tasks , tags = [GraalPythonTags .unittest_posix ]) as task :
1445
1484
if task :
1446
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1447
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1485
+ run_python_unittests (graalpy_standalone_jvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1486
+ run_python_unittests (graalpy_standalone_jvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1448
1487
1449
1488
with Task ('GraalPython standalone module tests' , tasks , tags = [GraalPythonTags .unittest_standalone ]) as task :
1450
1489
if task :
1451
1490
env = {
1452
1491
'ENABLE_STANDALONE_UNITTESTS' : 'true' ,
1453
1492
'JAVA_HOME' : graalvm_jdk (),
1454
- 'PYTHON_STANDALONE_HOME' : graalpy_standalone ( )
1493
+ 'PYTHON_STANDALONE_HOME' : graalpy_standalone_home ( 'jvm' )
1455
1494
}
1456
1495
mvn_repo_path = deploy_local_maven_repo ()
1457
1496
# setup maven downloader overrides
@@ -1470,20 +1509,20 @@ def graalpython_gate_runner(args, tasks):
1470
1509
with Task ('GraalPython Python tests' , tasks , tags = [GraalPythonTags .tagged ]) as task :
1471
1510
if task :
1472
1511
# don't fail this task if we're running with the jacoco agent, we know that some tests don't pass with it enabled
1473
- run_tagged_unittests (python_svm (), nonZeroIsFatal = (not is_collecting_coverage ()), report = report ())
1512
+ run_tagged_unittests (graalpy_standalone_native (), nonZeroIsFatal = (not is_collecting_coverage ()), report = report ())
1474
1513
1475
1514
with Task ('GraalPython sandboxed Python tests' , tasks , tags = [GraalPythonTags .tagged_sandboxed ]) as task :
1476
1515
if task :
1477
- run_tagged_unittests (python_managed_gvm (), checkIfWithGraalPythonEE = True , cwd = SUITE .dir , report = report ())
1516
+ run_tagged_unittests (graalpy_standalone_native_managed (), checkIfWithGraalPythonEE = True , cwd = SUITE .dir , report = report ())
1478
1517
1479
1518
# Unittests on SVM
1480
1519
with Task ('GraalPython tests on SVM' , tasks , tags = [GraalPythonTags .svmunit , GraalPythonTags .windows ]) as task :
1481
1520
if task :
1482
- run_python_unittests (python_svm (), exclude = excluded_tests , aot_compatible = True , report = report ())
1521
+ run_python_unittests (graalpy_standalone_native (), exclude = excluded_tests , aot_compatible = True , report = report ())
1483
1522
1484
1523
with Task ('GraalPython sandboxed tests on SVM' , tasks , tags = [GraalPythonTags .svmunit_sandboxed ]) as task :
1485
1524
if task :
1486
- run_python_unittests (python_managed_svm (), aot_compatible = True , report = report ())
1525
+ run_python_unittests (graalpy_standalone_native_managed (), aot_compatible = True , report = report ())
1487
1526
1488
1527
with Task ('GraalPython license header update' , tasks , tags = [GraalPythonTags .license ]) as task :
1489
1528
if task :
@@ -2348,7 +2387,7 @@ def python_coverage(args):
2348
2387
'--exclude-src-gen' ,
2349
2388
], env = env )
2350
2389
if args .truffle :
2351
- executable = python_gvm ()
2390
+ executable = graalpy_standalone_jvm ()
2352
2391
file_filter = f"*lib-graalpython*,*graalpython/include*,*com.oracle.graal.python.cext*,*lib/graalpy{ graal_version_short ()} *,*include/python{ py_version_short ()} *"
2353
2392
if os .environ .get ("TAGGED_UNITTEST_PARTIAL" ):
2354
2393
variants = [
@@ -2430,7 +2469,7 @@ def python_coverage(args):
2430
2469
f .name
2431
2470
], env = None )
2432
2471
2433
- home_launcher = os .path .join ( os . path . dirname (os .path .dirname (executable )), 'languages/python' )
2472
+ home_launcher = os .path .dirname (os .path .dirname (executable ))
2434
2473
suite_dir = SUITE .dir
2435
2474
if suite_dir .endswith ("/" ):
2436
2475
suite_dir = suite_dir [:- 1 ]
@@ -3010,7 +3049,6 @@ def processDeps(self, deps):
3010
3049
'python-style' : [python_style_checks , '[--fix] [--no-spotbugs]' ],
3011
3050
'python-svm' : [no_return (python_svm ), '' ],
3012
3051
'python-gvm' : [no_return (python_gvm ), '' ],
3013
- 'python-managed-gvm' : [no_return (python_managed_gvm ), '' ],
3014
3052
'python-unittests' : [python3_unittests , '' ],
3015
3053
'python-compare-unittests' : [compare_unittests , '' ],
3016
3054
'python-retag-unittests' : [retag_unittests , '' ],
0 commit comments