[IronPython] Using pyc.py to make stand-alone executables

Michael Foord fuzzyman at voidspace.org.uk
Thu Jun 19 13:48:19 PDT 2008

joeymcjoejoe wrote:
> I seem to be having a problem compiling a stand-alone exe file out of my
> code.
> my code is essentially pure Python. I'm using just using System.IO to get
> the FileSystemWatcher.
> The regular python modules I'm using are these:
> import sys
> sys.path.append(r'C:\Python25\Lib')
> import os
> import time
> import datetime
> import re
> import shutil
> import ConfigParser
> import string
> import smtplib
> import email.Message
> When I run this line:
> ipy.exe pyc.py /main:myprogram.py
> I get an executable that removes the need for IronPython on the client. It
> will run on the compiling machine, plus any other machine with Python
> installled.

You still need the IronPython assemblies of course.

> But without Python installed, it won't run.So I think I need to include
> those resources in the compile command, no?
> How do I include those regular python modules? The pyc sample readme only
> shows how to take the .Net modules in. What is the proper syntax I need to
> use? My guess is /res: ?

No - the modules need to be available to import in the usual way. You 
can compile these as well if you want.

> And which ones do I take? The uncompiled ones? 
> Also email.Message is in its own directory "Email\message.py" 

This is a Python package. Even if you ship it compiled it will still 
need to be in a directory like this for the Python import to work.

Michael Foord

> Some I can't even find in the Lib directory, e.g.: sys, time, datetime. What
> do I do in that case?


More information about the Users mailing list