Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate .NET Assemblies from Iron Python

I have a Iron Python script that I want to run and then have the ipy interpreter output an assembly that I can run on other machines. How do I do that? Is there a switch I can pass to ipy.exe?

like image 680
Leo Bontemps Avatar asked Mar 13 '10 04:03

Leo Bontemps


1 Answers

Using SharpDevelop

One way to is to use SharpDevelop, it builds assemblies (executables and class libraries) easily.

The process is straightforward:

  • Create a Python solution (Choices include: Class lib, Console or Windows application)
  • Write your Python code as normal
  • Build your solution or project

The .exe and .dll files will be in the relevant build output directory (Debug or Release).


Using pyc.py

Another way is to the IronPython command line compiler script called pyc.py.

The compiler script can be found in the directory: [IP_install_dir]\Tools\Scripts

Usage:
ipy.exe pyc.py /main:Program.py Form.py /target:winexe


Note: To get the compiled exe to run you will need the following files in the same directory as your executable:

IronPython.dll
IronPython.Modules.dll
Microsoft.Dynamic.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.dll
Microsoft.Scripting.ExtensionAttribute.dll
like image 77
Philip Fourie Avatar answered Sep 18 '22 15:09

Philip Fourie