@@ -945,17 +945,86 @@ def _join_bin(home, name):
945
945
return os .path .join (home , "bin" , name )
946
946
947
947
948
- def graalpy_standalone ():
948
+ def _graalpy_launcher (managed = False ):
949
+ name = 'graalpy-managed' if managed else 'graalpy'
950
+ return f"{ name } .exe" if WIN32 else name
951
+
952
+
953
+ def graalpy_standalone_home (standalone_type , enterprise = False ):
954
+ assert standalone_type in ['native' , 'jvm' ]
949
955
jdk_version = mx .get_jdk ().javaCompliance # Not our "get_jdk", because we do not want the jvmci tag.
950
- mx_args = ['-p' , os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' ), '--env' , 'ce-python' ]
951
- if not DISABLE_REBUILD :
952
- mx .run_mx (mx_args + ["build" , "--dep" , f"PYTHON_JAVA_STANDALONE_SVM_JAVA{ jdk_version } " ])
953
- out = mx .OutputCapture ()
954
- mx .run_mx (mx_args + ["standalone-home" , "--type" , "jvm" , "python" ], out = out )
955
- python_home = out .data .splitlines ()[- 1 ].strip ()
956
+ python_home = os .environ .get ("GRAALPY_HOME" , None )
957
+ if python_home and "*" in python_home :
958
+ python_home = os .path .abspath (glob .glob (python_home )[0 ])
959
+ mx .log ("Using GraalPy standalone from GRAALPY_HOME: " + python_home )
960
+ # Try to verify that we're getting what we expect:
961
+ has_java = os .path .exists (os .path .join (python_home , 'jvm' , 'bin' , 'java' ))
962
+ if has_java != (standalone_type == 'jvm' ):
963
+ mx .abort (f"GRAALPY_HOME is not compatible with the requested distribution type.\n "
964
+ f"jvm/bin/java exists?: { has_java } , requested type={ standalone_type } ." )
965
+
966
+ line = ''
967
+ with open (os .path .join (python_home , 'release' ), 'r' ) as f :
968
+ while 'JAVA_VERSION=' not in line :
969
+ line = f .readline ()
970
+ if 'JAVA_VERSION=' not in line :
971
+ mx .abort (f"GRAALPY_HOME does not contain 'release' file. Cannot check Java version." )
972
+ actual_jdk_version = line .strip ('JAVA_VERSION=' ).strip (' "\n \r ' )
973
+ if actual_jdk_version != jdk_version :
974
+ mx .abort (f"GRAALPY_HOME is not compatible with the requested JDK version.\n "
975
+ f"actual version: '{ actual_jdk_version } ', version string: { line } , requested version: { jdk_version } ." )
976
+
977
+ launcher = os .path .join (python_home , 'bin' , _graalpy_launcher (enterprise ))
978
+ out = mx .OutputCapture ()
979
+ import_managed_status = mx .run ([launcher , "-c" , "import __graalpython_enterprise__" ], nonZeroIsFatal = False , out = out , err = out )
980
+ if enterprise != (import_managed_status == 0 ):
981
+ mx .abort (f"GRAALPY_HOME is not compatible with requested distribution kind ({ import_managed_status = } , { enterprise = } , { out = } )." )
982
+ else :
983
+ env_file = 'ce-python'
984
+ vm_suite_path = os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' )
985
+ svm_distr = ''
986
+ if enterprise :
987
+ env_file = 'ee-python'
988
+ vm_suite_path = os .path .join (mx .suite ('graal-enterprise' ).dir , '..' , 'vm-enterprise' )
989
+ svm_distr = '_SVMEE'
990
+ mx_args = ['-p' , vm_suite_path , '--env' , env_file ]
991
+ if not DISABLE_REBUILD :
992
+ dep_type = 'JAVA' if standalone_type == 'jvm' else 'NATIVE'
993
+ mx .run_mx (mx_args + ["build" , "--dep" , f"PYTHON_{ dep_type } _STANDALONE_SVM{ svm_distr } _JAVA{ jdk_version } " ])
994
+ out = mx .OutputCapture ()
995
+ mx .run_mx (mx_args + ["standalone-home" , "--type" , standalone_type , "python" ], out = out )
996
+ python_home = out .data .splitlines ()[- 1 ].strip ()
956
997
return python_home
957
998
958
999
1000
+ def graalpy_standalone (standalone_type , managed = False ):
1001
+ assert standalone_type in ['native' , 'jvm' ]
1002
+ if standalone_type == 'native' and mx_gate .get_jacoco_agent_args ():
1003
+ return graalpy_standalone ('jvm' )
1004
+
1005
+ launcher = os .path .join (graalpy_standalone_home (standalone_type , managed ), 'bin' , _graalpy_launcher (managed ))
1006
+ return make_coverage_launcher_if_needed (launcher )
1007
+
1008
+ def graalpy_standalone_jvm ():
1009
+ return graalpy_standalone ('jvm' )
1010
+
1011
+
1012
+ def graalpy_standalone_native ():
1013
+ return graalpy_standalone ('native' )
1014
+
1015
+
1016
+ def graalpy_standalone_jvm_managed ():
1017
+ return graalpy_standalone ('jvm' , managed = True )
1018
+
1019
+
1020
+ def graalpy_standalone_jvm_enterprise ():
1021
+ return os .path .join (graalpy_standalone_home ('jvm' , enterprise = True ), 'bin' , _graalpy_launcher (managed = False ))
1022
+
1023
+
1024
+ def graalpy_standalone_native_managed ():
1025
+ return graalpy_standalone ('native' , managed = True )
1026
+
1027
+
959
1028
def graalvm_jdk ():
960
1029
jdk_version = mx .get_jdk ().javaCompliance # Not our "get_jdk", because we do not want the jvmci tag.
961
1030
mx_args = ['-p' , os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' ), '--env' , 'ce' ]
@@ -995,8 +1064,12 @@ def deploy_local_maven_repo():
995
1064
996
1065
def python_gvm (_ = None ):
997
1066
home = _graalvm_home (envfile = "graalpython-bash-launcher" )
998
- launcher = _join_bin (home , "graalpy" )
1067
+ launcher = make_coverage_launcher_if_needed (_join_bin (home , "graalpy" ))
1068
+ mx .log (launcher )
1069
+ return launcher
1070
+
999
1071
1072
+ def make_coverage_launcher_if_needed (launcher ):
1000
1073
if mx_gate .get_jacoco_agent_args ():
1001
1074
# patch our launchers created under jacoco to also run with jacoco.
1002
1075
# do not use is_collecting_coverage() here, we only want to patch when
@@ -1007,6 +1080,7 @@ def graalvm_vm_arg(java_arg):
1007
1080
java_arg = f .read ()
1008
1081
assert java_arg [0 ] == "-" , java_arg
1009
1082
return shlex .quote (f'--vm.{ java_arg [1 :]} ' )
1083
+
1010
1084
agent_args = ' ' .join (graalvm_vm_arg (arg ) for arg in mx_gate .get_jacoco_agent_args () or [])
1011
1085
1012
1086
# We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher
@@ -1019,23 +1093,7 @@ def graalvm_vm_arg(java_arg):
1019
1093
f .write (f'{ original_launcher } --jvm { exe_arg } { agent_args } "$@"\n ' )
1020
1094
os .chmod (bash_launcher , 0o775 )
1021
1095
mx .log (f"Replaced { launcher } with { bash_launcher } to collect coverage" )
1022
- return bash_launcher
1023
-
1024
- mx .log (launcher )
1025
- return launcher
1026
-
1027
-
1028
- def python_managed_gvm (_ = None ):
1029
- home = _graalvm_home (envfile = "graalpython-managed-bash-launcher" )
1030
- launcher = _join_bin (home , "graalpy-managed" )
1031
- mx .log (launcher )
1032
- return launcher
1033
-
1034
-
1035
- def python_enterprise_gvm (_ = None ):
1036
- home = _graalvm_home (envfile = "graalpython-managed-bash-launcher" )
1037
- launcher = _join_bin (home , "graalpy" )
1038
- mx .log (launcher )
1096
+ launcher = bash_launcher
1039
1097
return launcher
1040
1098
1041
1099
@@ -1048,13 +1106,6 @@ def python_svm(_=None):
1048
1106
return launcher
1049
1107
1050
1108
1051
- def python_managed_svm ():
1052
- home = _graalvm_home (envfile = "graalpython-managed-launcher" )
1053
- launcher = _join_bin (home , "graalpy-managed" )
1054
- mx .log (launcher )
1055
- return launcher
1056
-
1057
-
1058
1109
def native_image (args ):
1059
1110
mx .run_mx ([
1060
1111
"-p" , os .path .join (mx .suite ("truffle" ).dir , ".." , "substratevm" ),
@@ -1071,14 +1122,6 @@ def native_image(args):
1071
1122
])
1072
1123
1073
1124
1074
- def python_so ():
1075
- return _graalvm_home (envfile = "graalpython-libpolyglot" )
1076
-
1077
-
1078
- def python_managed_so ():
1079
- return _graalvm_home (envfile = "graalpython-managed-libpolyglot" )
1080
-
1081
-
1082
1125
def _graalpytest_driver ():
1083
1126
return os .path .join (SUITE .dir , "graalpython" , "com.oracle.graal.python.test" , "src" , "graalpytest.py" )
1084
1127
@@ -1524,7 +1567,7 @@ def graalpython_gate_runner(args, tasks):
1524
1567
if not WIN32 :
1525
1568
mx .run (["env" ])
1526
1569
run_python_unittests (
1527
- python_gvm (),
1570
+ graalpy_standalone_jvm (),
1528
1571
javaAsserts = True ,
1529
1572
exclude = excluded_tests ,
1530
1573
nonZeroIsFatal = nonZeroIsFatal ,
@@ -1544,39 +1587,35 @@ def graalpython_gate_runner(args, tasks):
1544
1587
1545
1588
with Task ('GraalPython sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_sandboxed ]) as task :
1546
1589
if task :
1547
- run_python_unittests (python_managed_gvm (), javaAsserts = True , exclude = excluded_tests , report = report ())
1590
+ run_python_unittests (graalpy_standalone_native_managed (), javaAsserts = True , exclude = excluded_tests , report = report ())
1548
1591
1549
1592
with Task ('GraalPython multi-context unittests' , tasks , tags = [GraalPythonTags .unittest_multi ]) as task :
1550
1593
if task :
1551
- run_python_unittests (python_gvm (), args = ["-multi-context" ], javaAsserts = True , exclude = excluded_tests , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1594
+ run_python_unittests (graalpy_standalone_jvm (), args = ["-multi-context" ], javaAsserts = True , exclude = excluded_tests , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1552
1595
1553
1596
with Task ('GraalPython Jython emulation tests' , tasks , tags = [GraalPythonTags .unittest_jython ]) as task :
1554
1597
if task :
1555
- run_python_unittests (python_gvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ], javaAsserts = True , report = report (), nonZeroIsFatal = nonZeroIsFatal )
1556
-
1557
- with Task ('GraalPython ginstall' , tasks , tags = [GraalPythonTags .ginstall ], report = True ) as task :
1558
- if task :
1559
- run_ginstall (python_gvm (), args = ["--quiet" ])
1598
+ run_python_unittests (graalpy_standalone_jvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ], javaAsserts = True , report = report (), nonZeroIsFatal = nonZeroIsFatal )
1560
1599
1561
1600
with Task ('GraalPython HPy tests' , tasks , tags = [GraalPythonTags .unittest_hpy ]) as task :
1562
1601
if task :
1563
- run_hpy_unittests (python_svm (), nonZeroIsFatal = nonZeroIsFatal , report = report ())
1602
+ run_hpy_unittests (graalpy_standalone_native (), nonZeroIsFatal = nonZeroIsFatal , report = report ())
1564
1603
1565
1604
with Task ('GraalPython HPy sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_hpy_sandboxed ]) as task :
1566
1605
if task :
1567
- run_hpy_unittests (python_managed_svm (), include_native = False , report = report ())
1606
+ run_hpy_unittests (graalpy_standalone_native_managed (), include_native = False , report = report ())
1568
1607
1569
1608
with Task ('GraalPython posix module tests' , tasks , tags = [GraalPythonTags .unittest_posix ]) as task :
1570
1609
if task :
1571
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1572
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1610
+ run_python_unittests (graalpy_standalone_jvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1611
+ run_python_unittests (graalpy_standalone_jvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report ())
1573
1612
1574
1613
with Task ('GraalPython standalone module tests' , tasks , tags = [GraalPythonTags .unittest_standalone ]) as task :
1575
1614
if task :
1576
1615
env = {
1577
1616
'ENABLE_STANDALONE_UNITTESTS' : 'true' ,
1578
1617
'JAVA_HOME' : graalvm_jdk (),
1579
- 'PYTHON_STANDALONE_HOME' : graalpy_standalone ( )
1618
+ 'PYTHON_STANDALONE_HOME' : graalpy_standalone_home ( 'jvm' )
1580
1619
}
1581
1620
mvn_repo_path = deploy_local_maven_repo ()
1582
1621
# setup maven downloader overrides
@@ -1595,20 +1634,20 @@ def graalpython_gate_runner(args, tasks):
1595
1634
with Task ('GraalPython Python tests' , tasks , tags = [GraalPythonTags .tagged ]) as task :
1596
1635
if task :
1597
1636
# don't fail this task if we're running with the jacoco agent, we know that some tests don't pass with it enabled
1598
- run_tagged_unittests (python_svm (), nonZeroIsFatal = (not is_collecting_coverage ()), report = report ())
1637
+ run_tagged_unittests (graalpy_standalone_native (), nonZeroIsFatal = (not is_collecting_coverage ()), report = report ())
1599
1638
1600
1639
with Task ('GraalPython sandboxed Python tests' , tasks , tags = [GraalPythonTags .tagged_sandboxed ]) as task :
1601
1640
if task :
1602
- run_tagged_unittests (python_managed_gvm (), checkIfWithGraalPythonEE = True , cwd = SUITE .dir , report = report ())
1641
+ run_tagged_unittests (graalpy_standalone_native_managed (), checkIfWithGraalPythonEE = True , cwd = SUITE .dir , report = report ())
1603
1642
1604
1643
# Unittests on SVM
1605
1644
with Task ('GraalPython tests on SVM' , tasks , tags = [GraalPythonTags .svmunit , GraalPythonTags .windows ]) as task :
1606
1645
if task :
1607
- run_python_unittests (python_svm (), exclude = excluded_tests , aot_compatible = True , report = report ())
1646
+ run_python_unittests (graalpy_standalone_native (), exclude = excluded_tests , aot_compatible = True , report = report ())
1608
1647
1609
1648
with Task ('GraalPython sandboxed tests on SVM' , tasks , tags = [GraalPythonTags .svmunit_sandboxed ]) as task :
1610
1649
if task :
1611
- run_python_unittests (python_managed_svm (), aot_compatible = True , report = report ())
1650
+ run_python_unittests (graalpy_standalone_native_managed (), aot_compatible = True , report = report ())
1612
1651
1613
1652
with Task ('GraalPython license header update' , tasks , tags = [GraalPythonTags .license ]) as task :
1614
1653
if task :
@@ -2463,7 +2502,7 @@ def python_coverage(args):
2463
2502
'--exclude-src-gen' ,
2464
2503
], env = env )
2465
2504
if args .truffle :
2466
- executable = python_gvm ()
2505
+ executable = graalpy_standalone_jvm ()
2467
2506
file_filter = f"*lib-graalpython*,*graalpython/include*,*com.oracle.graal.python.cext*,*lib/graalpy{ graal_version_short ()} *,*include/python{ py_version_short ()} *"
2468
2507
if os .environ .get ("TAGGED_UNITTEST_PARTIAL" ):
2469
2508
variants = [
@@ -2546,7 +2585,7 @@ def python_coverage(args):
2546
2585
f .name
2547
2586
], env = None )
2548
2587
2549
- home_launcher = os .path .join ( os . path . dirname (os .path .dirname (executable )), 'languages/python' )
2588
+ home_launcher = os .path .dirname (os .path .dirname (executable ))
2550
2589
suite_dir = SUITE .dir
2551
2590
if suite_dir .endswith ("/" ):
2552
2591
suite_dir = suite_dir [:- 1 ]
@@ -3088,7 +3127,6 @@ def processDeps(self, deps):
3088
3127
'python-style' : [python_style_checks , '[--fix] [--no-spotbugs]' ],
3089
3128
'python-svm' : [no_return (python_svm ), '' ],
3090
3129
'python-gvm' : [no_return (python_gvm ), '' ],
3091
- 'python-managed-gvm' : [no_return (python_managed_gvm ), '' ],
3092
3130
'python-unittests' : [python3_unittests , '' ],
3093
3131
'python-compare-unittests' : [compare_unittests , '' ],
3094
3132
'python-retag-unittests' : [retag_unittests , '' ],
0 commit comments