@@ -116,7 +116,8 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, **kwargs):
116
116
args .insert (0 , "--python.CAPI=%s" % capi_home )
117
117
118
118
if not env :
119
- env = os .environ
119
+ env = os .environ .copy ()
120
+ env .setdefault ("GRAAL_PYTHONHOME" , _dev_pythonhome ())
120
121
121
122
check_vm_env = env .get ('GRAALPYTHON_MUST_USE_GRAAL' , False )
122
123
if check_vm_env :
@@ -163,14 +164,27 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, **kwargs):
163
164
return mx .run_java (vm_args + graalpython_args , jdk = jdk , env = env , ** kwargs )
164
165
165
166
167
+ def _pythonhome_context ():
168
+ return set_env (GRAAL_PYTHONHOME = mx .dependency ("GRAALPYTHON_GRAALVM_SUPPORT" ).get_output ())
169
+
170
+
171
+ def _dev_pythonhome_context ():
172
+ home = os .environ .get ("GRAAL_PYTHONHOME" , _dev_pythonhome ())
173
+ return set_env (GRAAL_PYTHONHOME = home )
174
+
175
+
176
+ def _dev_pythonhome ():
177
+ return os .path .join (SUITE .dir , "graalpython" )
178
+
179
+
166
180
def punittest (ars ):
167
181
if '--regex' not in ars :
168
182
args = ['--regex' , r'(graal\.python)|(com\.oracle\.truffle\.tck\.tests)' ]
169
183
args += ["-Dgraal.TruffleCompilationExceptionsAreFatal=false" ,
170
184
"-Dgraal.TruffleCompilationExceptionsArePrinted=true" ,
171
185
"-Dgraal.TrufflePerformanceWarningsAreFatal=false" ]
172
186
args += ars
173
- with set_env ( GRAAL_PYTHONHOME = mx . dependency ( "GRAALPYTHON_GRAALVM_SUPPORT" ). get_output () ):
187
+ with _pythonhome_context ( ):
174
188
mx_unittest .unittest (args )
175
189
176
190
@@ -190,7 +204,7 @@ def nativeclean(args):
190
204
191
205
def python3_unittests (args ):
192
206
"""run the cPython stdlib unittests"""
193
- mx . run ([ "python3" , "graalpython/com.oracle.graal.python.test/src/python_unittests.py" , "-v" ] + args )
207
+ python ([ "graalpython/com.oracle.graal.python.test/src/python_unittests.py" , "-v" ] + args )
194
208
195
209
196
210
def retag_unittests (args ):
@@ -619,7 +633,7 @@ def run_shared_lib_test(args=None):
619
633
mx .log ("Running " + progname + " with LD_LIBRARY_PATH " + svm_lib_path )
620
634
mx .run (["ls" , "-l" , progname ])
621
635
mx .run (["ls" , "-l" , svm_lib_path ])
622
- run_env = {"LD_LIBRARY_PATH" : svm_lib_path , "GRAAL_PYTHONHOME" : os . environ [ "GRAAL_PYTHONHOME" ] }
636
+ run_env = {"LD_LIBRARY_PATH" : svm_lib_path , "GRAAL_PYTHONHOME" : _dev_pythonhome () }
623
637
mx .log (repr (run_env ))
624
638
mx .run ([progname ], env = run_env )
625
639
finally :
@@ -1011,18 +1025,6 @@ def verify_ci(dest_suite, common_ci_dir="ci_common", args=None, ext=('.jsonnet',
1011
1025
))
1012
1026
1013
1027
1014
- # ----------------------------------------------------------------------------------------------------------------------
1015
- #
1016
- # set our GRAAL_PYTHONHOME if not already set
1017
- #
1018
- # ----------------------------------------------------------------------------------------------------------------------
1019
- if not os .getenv ("GRAAL_PYTHONHOME" ):
1020
- home = os .path .join (SUITE .dir , "graalpython" )
1021
- if not os .path .exists (home ):
1022
- home = [d for d in SUITE .dists if d .name == "GRAALPYTHON_GRAALVM_SUPPORT" ][0 ].output
1023
- os .environ ["GRAAL_PYTHONHOME" ] = home
1024
-
1025
-
1026
1028
# ----------------------------------------------------------------------------------------------------------------------
1027
1029
#
1028
1030
# post init
@@ -1144,7 +1146,7 @@ def __init__(self, args, project):
1144
1146
def __str__ (self ):
1145
1147
return 'Building C API project {} with setuptools' .format (self .subject .name )
1146
1148
1147
- def run (self , args , env , cwd ):
1149
+ def run (self , args , env = None , cwd = None ):
1148
1150
return do_run_python (args , env = env , cwd = cwd )
1149
1151
1150
1152
def _dev_headers_dir (self ):
@@ -1168,7 +1170,6 @@ def build(self):
1168
1170
# importlib PathFinder initializes it's directory finders
1169
1171
mx .ensure_dir_exists (os .path .join (self .subject .get_output_root (), "modules" ))
1170
1172
1171
- env = os .environ .copy ()
1172
1173
cwd = os .path .join (self .subject .get_output_root (), "mxbuild_temp" )
1173
1174
args = []
1174
1175
if mx ._opts .verbose :
@@ -1177,7 +1178,7 @@ def build(self):
1177
1178
args .append ("-q" )
1178
1179
args += ["-S" , os .path .join (self .src_dir (), "setup.py" ), self .subject .get_output_root ()]
1179
1180
mx .ensure_dir_exists (cwd )
1180
- rc = self .run (args , env = env , cwd = cwd )
1181
+ rc = self .run (args , cwd = cwd )
1181
1182
shutil .rmtree (cwd ) # remove the temporary build files
1182
1183
return min (rc , 1 )
1183
1184
0 commit comments