[IronPython] How to compile has a DLL assembly ?

Dino Viehland dinov at exchange.microsoft.com
Mon Jul 24 17:25:49 CEST 2006

The easiest way to compile something is to run it w/ -X:SaveAssembiles:

Ipy.exe -X:SaveAssemblies toto.py

Will write out a toto.exe.  Then you can just do an AppDomain.CurrentDomain.ExecuteAssembly on that and it'll run.  Note you won't be able to get at the classes defined in the assembly from the .NET code.

If you just want to compile & run inside of your process you're probably better off using the PythonEngine APIs which provide compile & execute functionality, but this won't allow you to save it to disk.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Prince0
Sent: Saturday, July 22, 2006 1:36 AM
To: users at lists.ironpython.com
Subject: [IronPython] How to compile has a DLL assembly ?

I have compiled my Python script and now I would like to use it as a standard DLL assembly.
How can I do this?

Here's my current code:
List<string> files = new List<string>();
PythonCompiler compiler = new PythonCompiler(files, @"c:\toto.dll");
private toto toto1;
this.toto1 = new toto();
      PythonModule pm = Ops.InitializeModule(this.toto1, "toto", new string[0]);
      pm.SystemState.stdout = new PythonFile(File.Create(@"c:\output.txt"), Encoding.ASCII, "output", "w");
Ops.ExecuteCompiled(new InitializeModule(this.toto1.Initialize));

Is there a better way? It seems I will have to modify IronPython's source code so I can also specify the args.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060724/aa3f79e4/attachment.html>

More information about the Ironpython-users mailing list