Rob Austein d357e02b5d Try telling BlackFriday to use text mode. | %!s(int64=5) %!d(string=hai) anos | |
---|---|---|
demo1 | %!s(int64=5) %!d(string=hai) anos | |
demo2 | %!s(int64=5) %!d(string=hai) anos | |
.gitignore | %!s(int64=5) %!d(string=hai) anos | |
Makefile | %!s(int64=5) %!d(string=hai) anos | |
README.md | %!s(int64=5) %!d(string=hai) anos | |
pyzipper | %!s(int64=5) %!d(string=hai) anos |
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.
The Makefile
is just a driver for the demos. pyzipper
itself is
all you need if you want to use this yourself.
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.
This is what pyzipper --help
returns as of this writing. The
program itself is authoritative, this is just a snapshot for
convenience.
usage: pyzipper [-h] -o OUTPUT [-m MODULE] [-e EXECUTABLE] source
Generate an executable Python zip package.
positional arguments:
source
optional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
-m MODULE, --module MODULE
module within package to run (default: main)
-e EXECUTABLE, --executable EXECUTABLE
python executable to run (default: python)