@@ -259,7 +259,14 @@ def hosting_registry(self):
259259
260260 def run (self , cwd , args ):
261261 _check_vm_args (self .name (), args )
262+ extra_polyglot_args = ["--experimental-options" ]
262263
264+ host_vm = self .host_vm ()
265+ if hasattr (host_vm , 'run_lang' ): # this is a full GraalVM build
266+ with environ (self ._env or {}):
267+ return host_vm .run_lang ('graalpython' , extra_polyglot_args + args , cwd )
268+
269+ # Otherwise, we're running from the source tree
263270 truffle_options = [
264271 # '-Dgraal.TruffleCompilationExceptionsAreFatal=true'
265272 ]
@@ -278,7 +285,7 @@ def run(self, cwd, args):
278285 if mx .suite ("sulong-managed" , fatalIfMissing = False ):
279286 dists .append ('SULONG_MANAGED' )
280287
281- extra_polyglot_args += ["--experimental-options" , "-- python.CAPI=%s" % SUITE .extensions ._get_capi_home () ]
288+ extra_polyglot_args += ["--python.CAPI=%s" % SUITE .extensions ._get_capi_home ()]
282289
283290 vm_args = mx .get_runtime_jvm_args (dists , cp_suffix = self ._cp_suffix , cp_prefix = self ._cp_prefix )
284291 if isinstance (self ._extra_vm_args , list ):
@@ -293,14 +300,10 @@ def run(self, cwd, args):
293300 args .remove (a )
294301 cmd = truffle_options + vm_args + extra_polyglot_args + args
295302
296- host_vm = self .host_vm ()
297303 if not self ._env :
298304 self ._env = dict ()
299305 with environ (self ._env ):
300- if hasattr (host_vm , 'run_lang' ):
301- return host_vm .run_lang ('graalpython' , extra_polyglot_args + args , cwd )
302- else :
303- return host_vm .run (cwd , cmd )
306+ return host_vm .run (cwd , cmd )
304307
305308 def name (self ):
306309 return VM_NAME_GRAALPYTHON
0 commit comments