You can use pyc.py
, the Python Command-Line Compiler, which is included in IronPython since version 2.6 to compile a Python script to an executable. You find it at %IRONPYTONINSTALLDIR%\Tools\Scripts\pyc.py
on your hard disk.
Example
Let’s assume you have a simple script test.py
that just prints out something to console. You can turn this into an executable with the following command-line (assuming that the IronPython directory is the current directory and that test.py
is in there, too):
ipy.exe Tools\Scripts\pyc.py /main:test.py /target:exe
Note: If you are using forms and don’t want a console window to open, you want to use /target:winexe
instead of /target:exe
.
The result will be two files, test.dll
and test.exe
. test.dll
will contain your actual script code, while test.exe
is just a launcher for test.dll
. You can distribute this EXE and DLL to other computers which do not have IronPython installed if you include the files
IronPython.dll
,Microsoft.Dynamic.dll
,Microsoft.Scripting.Core.dll
,Microsoft.Scripting.Debugging.dll
,Microsoft.Scripting.dll
,Microsoft.Scripting.ExtensionAttribute.dll
andIronPython.Modules.dll
(sometimes needed).
Also see the blog entry IronPython – how to compile exe.