[IronPython] Python Command Line Compiler issues and questions

Patrick O'Brien sum.ergo.code at gmail.com
Mon Jan 1 00:00:39 CET 2007


If you compile a python module using PYC and run the resulting executable,
the module name is no longer '__main__' and so you cannot make use of the
popular idiom:

if __name__ == '__main__':

If you don't use that idiom it makes it impossible to unit test any
functions in your main module because running the unit tests imports the
module and runs the main code.  The alternative is to have the main module
be as small as possible and put the bulk of the functionality into other
modules that get imported by the main module.  Which would be fine if there
was a way to include those modules in the resulting exe created by PYC, but
that doesn't seem to happen for me.  Which means the .py files would have to
ship as well as the .exe and the two .dll files (IronMath.dll and
IronPython.dll).  And substituting a .pyo file does not work, so what would
ship in my app is the source code and for this particular app that would not
be a good thing.

The PYC program lets you specify multiple .py files, but I don't understand
what that means.  One file can be marked as main, which is what gets
executed.  What I don't understand is how the other .py files get used.  The
one example of this in the documentation was not terribly helpful for me.

Anyone have any suggestions?  Did I miss something in my understanding of
PYC?  How are others packaging their IronPython apps for distribution to
customers?

-- 
Patrick K. O'Brien
Orbtech       http://www.orbtech.com
Schevo        http://www.schevo.org
Louie         http://www.pylouie.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20061231/0ee4a736/attachment.html>


More information about the Ironpython-users mailing list