py2bin is a hassle-free, command-line-tool that allows you to easily convert a Python file into a binary file with a single line of code.
py2bin is a streamlined version of and built from: PyInstaller.
- minimal command-line-interface
- easier resource integration
- cleaner output and file handling
- constrained functionality
- Mac OSX
- Python >= 3.6
Installation | Usage | |
---|---|---|
Homebrew | $ brew install dante-biase/x2x/py2bin | $ py2bin PY_FILE [OPTIONS] |
Manual | $ git clone https://github.com/dante-biase/py2bin.git $ cd py2bin $ pip3 install -r requirements.txt $ chmod +x py2bin.py |
$ ./py2bin.py PY_FILE [OPTIONS] |
specifies the py file to be converted into a binary, required
-r, --resources_directory TEXT directory that contains binary resources
-d, --destination_directory TEXT directory to create the binary in
-o, --optimize TEXT compile with optimizations
--help print this message and exit
-
If your binary requires any resources, you must consolidate these files into a single directory -
resources_directory
-
Install py2x
$ pip3 install py2x
-
Add this import statement to any script that references resources you might need:
from py2x import Resources
-
Update references:
EXAMPLE: suppose you need to read a text file located within your
resources_directory
:change:
text_file = open("path/to/resources/file.txt", "r")
to:
text_file = open(Resources.get("file.txt"), "r")`
-
Execute py2bin while making sure to pass the path to your
resources_directory
to the-r
flag:py2bin main.py -r path/to/resources [OTHER OPTIONS]
- The output binary will be named with the stem of
PY_FILE
- If
destination_directory
is not specified, the binary will be placed in the same directory asPY_FILE