[Python-Dev] Computed Goto dispatch for Python 2
donald at stufft.io
Thu May 28 17:01:45 CEST 2015
On May 28, 2015 at 10:55:08 AM, Steve Dower (steve.dower at microsoft.com) wrote:
> Donald Stufft wrote:
> > I think docker is a pretty crummy answer to Go’s static binaries. What I would
> > love is for Python to get:
> > * The ability to import .so modules via zipzimport (ideally without a temporary
> > directory, but that might require newer APIs from libc and such).
> > * The ability to create a “static” Python that links everything it needs into
> > the binary to do a zipimport of everything else (including the stdlib).
> > * The ability to execute a zipfile that has been concat onto the end of the
> > Python binary.
> > I think that if we get all of that, we could easily create a single file
> > executable with real, native support from Python by simply compiling Python in
> > that static mode and then appending a zip file containing the standard library
> > and any other distributions we need to the end of it.
> And it would look like a 20MB+ file just for a simple 1KB Python script...
> For Windows at least, I'd prefer to have some app-style installer generation (e.g. http://pynsist.readthedocs.org/en/latest/)
> which, combined with the embeddable Python distro (new for 3.5.0b1 in case anyone missed
> it), can simply extract everything into an install directory and run it from there. None
> of the items on the list above are needed for or would help with this.
> (Some other Windows-specific advantages of the latter - installers get special compatibility
> treatment when the OS does stuff to break them, modifying official Python binaries breaks
> the signatures, signed executables are fully scanned before running (slow if the file
> is big), IT departments know how to deal with installers and users know how to deal with
> installed binaries, and probably more.)
> Alright everyone, back on topic now unless you want to rename the thread :)
Well Python 3.4.3 binary is 4kb for me, so you'd have that + your 1KB Python
script + whatever other pieces you need. It would be entirely possible to only
include the parts of the standard library you actually need. There's no rule
that if your single file executable doesn't use xmlrpc that you have to include
xmlrpc just for purities sake.
This isn't something that can't be done today using something like PyInstaller,
it's just super janky and finnicky because it's being hacked in after the fact
by PyInstaller and because it's not an officially supported thing a lot of
projects simply don't support it. A CLI I worked on that uses PyInstaller is
5MB. It's certainly a trade off but it's not nearly as big of a trade off as
PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
More information about the Python-Dev