public static void AddPythonStandardLibrary(ScriptingHosting.ScriptScope scope) { var thisAssembly = typeof(ScriptUtil).Assembly; var pythonLibResourceName = thisAssembly.GetManifestResourceNames() .Single(name => name.ToLowerInvariant().EndsWith(PYTHON_LIB_ZIP_NAME.ToLowerInvariant())); var importer = new IronPython.Modules.ResourceMetaPathImporter(thisAssembly, pythonLibResourceName); dynamic sysModule = IronPython.Hosting.Python.GetSysModule(scope.Engine); sysModule.meta_path.append(importer); return; }
public void AddEmbeddedLib(ScriptEngine engine) { // use embedded python lib var asm = this.GetType().Assembly; var resQuery = from name in asm.GetManifestResourceNames() where name.ToLowerInvariant().EndsWith(string.Format("python_{0}_lib.zip", EngineVersion)) select name; var resName = resQuery.Single(); var importer = new IronPython.Modules.ResourceMetaPathImporter(asm, resName); dynamic sys = IronPython.Hosting.Python.GetSysModule(engine); // sys.meta_path.append(importer); }
private void AddEmbeddedLib(ScriptEngine engine) { // use embedded python lib var asm = this.GetType().Assembly; var resQuery = from name in asm.GetManifestResourceNames() where name.ToLowerInvariant().EndsWith("python_27_lib.zip") select name; var resName = resQuery.Single(); var importer = new IronPython.Modules.ResourceMetaPathImporter(asm, resName); dynamic sys = IronPython.Hosting.Python.GetSysModule(engine); sys.meta_path.append(importer); }