Compiling an IronPython code to EXE or DLL
Asked Answered
I

3

9

Can I compile an IronPython code to EXE or DLL in a .NET runtime?

Interjoin answered 10/11, 2010 at 18:15 Comment(2)
possible duplicate of How do I create a .NET assembly in IronPython and call it from C#?Salesgirl
The duplicate question is a year and a half old, and we have dynamic types in C# now. Let's keep this question open.Leicestershire
L
6

Simply use clr.CompileModules in an IronPython script to convert it to a dll file. Or you can use pyc.py (found inside of your IronPythonInstallDirectory\Tools\Scripts) which can also generate an exe for you also.

Lodovico answered 10/11, 2010 at 22:53 Comment(1)
After we obtained the dll how do we use it? ScriptEngine don't have an option to crate scope from dll.Mellette
B
1

If I really, really needed that I would create a wrapper DLL/EXE in another language. The Python code can then be stored as a resource in the DLL that is loaded when the assembly is first accessed.

Bassist answered 10/11, 2010 at 19:12 Comment(0)
B
0

Yes you can! I posted a Python script which can take an IronPython file, figure out its dependencies and compile the lot into a standalone binary at Ironpython 2.6 .py -> .exe. Hope you find it useful.

Bye answered 7/3, 2012 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.