python compiler??

Alex Martelli aleaxit at yahoo.com
Tue Nov 7 07:40:30 EST 2000


"Maurice Ling" <htling at cyberway.com.sg> wrote in message
news:3A07CCC0.52105127 at cyberway.com.sg...
> Well, what I'm really interested in is, is there any python compiler that
can
> compile python codes into standalone executables?

See http://www.mcmillan-inc.com/install1.html -- he offers tools
to do that (which are *NOT* "python compilers") and points to a
few alternatives (which might conceivably be seen as "compilers"
in some sense -- at least, Python2C might be seen that way).

Basically, if the goal is "make a standalone executable", it
seems to me to be an over-specification error to add that this
task must be performed by "a Python compiler"; a "packager",
that is able to collect in a single, stand-alone executable
the various already-compiled-Python files (.pyc or .pyo) that
Python itself builds, plus the .pyc/.pyo/.pyd required by
them (from the standard library, other libraries, etc), seems
a reasonably acceptable architecture.  And this is basically
a description of Gordon McMillan's excellent "installer" (or,
at least, one of the ways you can make use of it).

The section of Gordon's notes that is specifically on
stand-alone executables will be found at
http://www.mcmillan-inc.com/standalones.html.

Note that only in the Windows version does he build
_truly_ totally self-contained executables -- "it's not
culturally appropriate" (and is technically harder, it
seems) to do that for Linux.  I'm not sure I understand
this (but then, my Linux knowledge dates mostly from
0.99 days -- I have heard executable/object formats have
indeed been changed drastically since those days).  But
it's an issue of C-written DLL's (.so's, in Linux), not
of any Python code -- apparently it's hard/inappropriate
to package up an executable together with all the DLL's
it needs.  Actually, very few do that in Windows, either --
at the very least, kernel32.dll, etc, are _never_ packaged
together with the .exe (or else the latter would run on
just ONE possible Windows configuration...), so, there is
really no such thing as "a truly, fully stand-alone exe".

But if it's OK for the C-written DLL's to remain "outside"
(to be unpackaged side-by-side with the almost-standalone
EXE, e.g. in the same directory), and you're only worried
about Python-code (and its compiled forms), then Gordon's
installer is probably the best available solution today.


Alex






More information about the Python-list mailing list