2009/8/18 Curt Hagenlocher <[email protected]> > using Microsoft.Scripting.Hosting.Providers.HostingHelpers. OK. but after imported not set data to the scope or the scriptscope.
| var scope = HostingHelpers.GetScope(scriptScope); | var codeContext = new CodeContext(scope, pythonContext); | Importer.Import(codeContext, main, new PythonTuple(), 0); | |: scope.Dict is empty 2009/8/18 Dino Viehland <[email protected]>: > What Curt says is true but I would suggest doing scriptRuntime.LoadAssembly > instead. > Once you do that you can do engine.ImportModule (an extension method defined > in the Python class) do get a ScriptSource for any of your compiled > modules. InitializeModule may change from major version to major version of > IronPython – but engine.ImportModule is a fixed public API. Thanks! I made it the following. | public static void InitializeModule(string ModulePath, string/*!*/ main) | { | var pythonEngine = Python.CreateEngine(); | var path = Path.GetFullPath(ModulePath); | var precompiled = Assembly.LoadFile(path); | | pythonEngine.Runtime.LoadAssembly(typeof(string).Assembly); | pythonEngine.Runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); | pythonEngine.Runtime.LoadAssembly(precompiled); | | var pythonContext = HostingHelpers.GetLanguageContext(pythonEngine) as PythonContext; | | try | { | scriptScope = pythonEngine.ImportModule(main); | } | catch (SystemExitException ex) | { | Console.WriteLine(ex.ToString()); | } | } But the problem dated ahead about UTF-8 parsing again :( To be fixed myself... _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
