What is the best way to freeze a Python 3 app (Windows)?

Paul Moore p.f.moore at gmail.com
Tue Apr 3 16:01:33 EDT 2012


I want to package up some of my Python 3 scripts to run standalone,
without depending on a system-installed Python. For my development, I
use virtualenv and install all my dependencies in the virtualenv,
develop the script and test it. When I'm done, I want to build an
executable which can run without depending on a system Python. What's
the best way of doing this? I previously would have used py2exe, but
that seems not to have Python 3 support. I have heard good things
about bbfreeze, but the author has stated that he has no intention of
supporting Python 3 just yet. I've tried cx_Freeze, but I've hit a
number of niggly problems which make me think it's not quite suitable
(I've reported some of them on the cx_Freeze mailing list, but it
seems pretty quiet - no real response).

That leaves me wondering if there's another option, or whether I
should just roll my own. if I zip up the stdlib, and my virtualenv
site-packages, and then put them plus the various Python DLLs in a
directory, copy my script in, and write a small EXE to set PYTHONHOME
and run Py_Main with my script as argument, that should do. But it
seems a bit laborious :-(

Is that really the best way?

Things I care about:
- Easy to package up a script
- Works with dependencies in a virtualenv
- Completely isolated from system Python (not even leaving directories
on sys.path, so I can do basic tests without having to create a clean
system with no Python installed).

Things I don't (really) care about:
- Stripping ununsed modules (although I'd like to omit "big" parts of
the stdlib that aren't used - tkinter and test come to mind)
- Space (the full stdlib is only 30M including pyc files, after all)

Any suggestions gratefully accepted :-)

Paul.



More information about the Python-list mailing list