Search code examples
.netdllironpythonexecutablepy2exe

How do I compile an IronPython app into an EXE without Visual Studios (and possibly with py2exe)?


So I tried searching for this answer before coming straight here to ask it. It definitely seems doable to turn an IronPython app/set of scripts into an EXE. The one issue is that they all seem to talk about using IronPython with IronPython Studios, a Python plugin for Visual Studios. Last I checked, I thought that IronPython Studios was basically replaced with the Python Tools for Visual Studios (or PTVS) plugin tool. The problem with this being that due to the way my code is structured, it actually managed to crash the plugin, and therefore Visual Studios, upon loading my code into the IDE. It will do so until the next scheduled update coming out at the end of the month or early next month. So that is not going to be an option as I've been having to develop my project in Eclipse instead with the PyDev plugin.

I have used py2exe to convert some basic Python applications into executables before, but that was when I was using the CPython interpreter. I don't know how I would set up py2exe to work with IronPython. Would it be possible to use py2exe to make an IronPython executable? And if my program uses extra C# assemblies to do its work, how would I set those up too so py2exe can use them and my executable can see them for referencing?


Solution

  • Pyc.py is the way to go as Python Tools for Visual Studio does not support direct compilation. SharpDevelop has custom build actions for Ironpython. I used #Develop until PTVS came out.

    See this question IronPython: EXE compiled using pyc.py cannot import module "os" for some detailed steps to follow to make your EXE. Remember to compile the standard lib modules you are using. If you have to make your users download and install IronPython then you wouldn't need to compile your script.