Can I compile an IronPython code to EXE or DLL in a .NET runtime?
Compiling an IronPython code to EXE or DLL
Asked Answered
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
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.
After we obtained the dll how do we use it? ScriptEngine don't have an option to crate scope from dll. –
Mellette
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.
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.
© 2022 - 2024 — McMap. All rights reserved.