4646import org .graalvm .polyglot .Context ;
4747import org .graalvm .polyglot .PolyglotException ;
4848import org .graalvm .polyglot .Source ;
49+ import org .graalvm .polyglot .io .IOAccess ;
4950
5051/**
5152 * A simple launcher for Python. The launcher sets the filesystem up to read the Python core,
@@ -68,24 +69,24 @@ public static void main(String[] args) throws IOException {
6869 String s = p .toString ();
6970 return s .endsWith (".so" ) || s .endsWith (".dylib" ) || s .endsWith (".pyd" ) || s .endsWith (".dll" );
7071 });
72+ IOAccess ioAccess = IOAccess .newBuilder ().fileSystem (vfs ).allowHostSocketAccess (true ).build ();
7173 var builder = Context .newBuilder ()
72- .allowExperimentalOptions (true )
73- .allowAllAccess (true )
74- .allowIO (true )
75- .fileSystem (vfs )
76- .arguments ("python" , Stream .concat (Stream .of (getProgramName ()), Stream .of (args )).toArray (String []::new ))
77- .option ("python.PosixModuleBackend" , "java" )
78- .option ("python.DontWriteBytecodeFlag" , "true" )
79- .option ("python.VerboseFlag" , System .getenv ("PYTHONVERBOSE" ) != null ? "true" : "false" )
80- .option ("log.python.level" , System .getenv ("PYTHONVERBOSE" ) != null ? "FINE" : "SEVERE" )
81- .option ("python.WarnOptions" , System .getenv ("PYTHONWARNINGS" ) == null ? "" : System .getenv ("PYTHONWARNINGS" ))
82- .option ("python.AlwaysRunExcepthook" , "true" )
83- .option ("python.ForceImportSite" , "true" )
84- .option ("python.RunViaLauncher" , "true" )
85- .option ("python.Executable" , vfs .resourcePathToPlatformPath (VENV_PREFIX ) + (VirtualFileSystem .isWindows () ? "\\ Scripts\\ python.cmd" : "/bin/python" ))
86- .option ("python.InputFilePath" , vfs .resourcePathToPlatformPath (PROJ_PREFIX ))
87- .option ("python.PythonHome" , vfs .resourcePathToPlatformPath (HOME_PREFIX ))
88- .option ("python.CheckHashPycsMode" , "never" );
74+ .allowExperimentalOptions (true )
75+ .allowAllAccess (true )
76+ .allowIO (ioAccess )
77+ .arguments ("python" , Stream .concat (Stream .of (getProgramName ()), Stream .of (args )).toArray (String []::new ))
78+ .option ("python.PosixModuleBackend" , "java" )
79+ .option ("python.DontWriteBytecodeFlag" , "true" )
80+ .option ("python.VerboseFlag" , System .getenv ("PYTHONVERBOSE" ) != null ? "true" : "false" )
81+ .option ("log.python.level" , System .getenv ("PYTHONVERBOSE" ) != null ? "FINE" : "SEVERE" )
82+ .option ("python.WarnOptions" , System .getenv ("PYTHONWARNINGS" ) == null ? "" : System .getenv ("PYTHONWARNINGS" ))
83+ .option ("python.AlwaysRunExcepthook" , "true" )
84+ .option ("python.ForceImportSite" , "true" )
85+ .option ("python.RunViaLauncher" , "true" )
86+ .option ("python.Executable" , vfs .resourcePathToPlatformPath (VENV_PREFIX ) + (VirtualFileSystem .isWindows () ? "\\ Scripts\\ python.cmd" : "/bin/python" ))
87+ .option ("python.InputFilePath" , vfs .resourcePathToPlatformPath (PROJ_PREFIX ))
88+ .option ("python.PythonHome" , vfs .resourcePathToPlatformPath (HOME_PREFIX ))
89+ .option ("python.CheckHashPycsMode" , "never" );
8990 if (ImageInfo .inImageRuntimeCode ()) {
9091 builder .option ("engine.WarnInterpreterOnly" , "false" );
9192 }
0 commit comments