A small tool to package up a Python program and associated data files
as a single executable zip file.
All the facilities for this are already built into Python, this script
just ties it all together with a bow.
demo1
and demo2
are two trivial sample packages.
Tested with both Python 2 and Python 3, should work with either.
This relies on two somewhat obscure Python features:
-
The zipfile.PyZipFile
class's ability to construct an executable
ZIP file and populate it with Python modules, packages, and data;
and
-
Python's ability to treat a zip file as equivalent to a directory
tree on import
.
demo1
takes advantage of a third obscure feature: the pkgutil
library's ability to load data files via the import
system.