Build instructions
Get a local copy of the code repository: either clone it or download and extract ZIP of latest
Install the dependencies [
pip3 install -r requirements.txt]Install
pyinstallerandsetuptools[pip3 install pyinstaller setuptools]Run
python3 setup.py band help text will print with the build options you can use. For example,python3 setup.py b -k onedirwill build retype with pyinstaller in onedir mode.
The output will be in /dist.
Build command options
Build options for the b command:
Build kinds
onedir
This is the bog-standard build. The result is a folder with many dependencies in dll and pyd files, as well as the retype executable and supporting directories (library, style).
This build kind is the safest option.
The downside of this kind of build is a messy resulting folder structure.
Expected output size: 30 MB
onefile
In this build all of the dependencies are packed into the executable. The result is a folder with just the retype executable and supporting directories (library, style).
library/
style/
retype executable
Additionally, because packing the dependencies into the executable compresses them, the result weighs about 10 MB less than with the other build kinds.
The downside of this kind of build is every time the executable is launched the dependencies packed into the executable need to first be extracted into a temporary directory.
Expected output size: 20 MB
hacky
In this build all of the dependencies are put into a subdirectory, include. It uses a hook that adds that directory to sys.path when the program is launched, and a modification of a pyinstaller loader.
For this build to work a modification has to first be made to pyinstaller’s file pyimod02_importers.py. The following line needs to be added after the imports and before SYS_PREFIX is set:
sys._MEIPASS = os.path.join(sys._MEIPASS, "include")
Warning
If you afterwards want to build with other options, you have to first comment out or remove this line.
Note
If using a version of PyInstaller lower than 5.3, the line should instead be sys._MEIPASS = pyi_os_path.os_path_join(sys._MEIPASS, "include"), and the file to modify is pyimod03_importers.py
The result is somewhere in between onedir and onefile; much cleaner resulting directory structure than onedir provides, without the need to extract files every launch.
include/
library/
style/
base_library.zip
python37.dll
retype executable
The obvious downside is it relies on a hack which could stop working or fail to work in certain environments.
Expected output size: 30 MB