py2bin
is a working example (not an installable or a library) demonstrating how to compile multi-module Python machine
learning applications into a single binary installable. Typically, Python libraries or components are distributed as
tarballs of pure Python code or C-extensions. However, distribution of end-user applications is difficult and somewhat
of an art form. Application distribution is not
as straightforward as in the Java, or even C world.
Typical path is to 'freeze' the application using the knowledge of your target system (Windows, Linux, or Mac) and using the appropriate freezing application. This repository is based on the Pyinstaller application.
As application developers, we desire the packaging system to be able to:
- work with the hierarchical Python package structure
- embed standard Python ML libraries (sklearn, keras, ...)
- embed numerical packages (scipy, numpy)
- embed and read non-python resource data (config files, data directories ...)
- create a single binary
Python application packaging problem has been around. There are multiple online tutorials dealing with a subset of the
above requirements. py2bin
shows how to address all of the above.
- Clone the repository.
- Make sure
numpy
,sklearn
andpyinstaller
are installed. - run
./compile.sh
- run
dist/main <integer>
e.g.dist/main 20