Container that can build single file Python apps with PyInstaller for Alpine Linux in a clean, isolated environment. The Forgejo container is built on Alpine Linux.
  • Makefile 47.4%
  • Shell 31.1%
  • Dockerfile 20.2%
  • Python 1.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-09-02 08:16:44 +02:00
bin Checks for setup.py and installs requirements if present 2016-12-02 13:53:30 -05:00
.gitignore Initial commit 2016-05-28 00:28:32 -05:00
build-all.sh More build version 2017-05-25 12:05:48 -05:00
build.sh Build pyinstaller-alpine image with alpine 3.12 and python 2.7 (#11) 2021-01-12 10:57:28 -06:00
Dockerfile Adjustments to work with a modern pyinstaller 2024-09-02 07:53:27 +02:00
example.py Initial commit 2016-05-28 00:28:32 -05:00
LICENSE Initial commit 2016-05-28 00:28:32 -05:00
Makefile Build pyinstaller-alpine image with alpine 3.12 and python 2.7 (#11) 2021-01-12 10:57:28 -06:00
README.md Point examples to hub.d.o 2024-09-02 08:16:44 +02:00

PyInstaller Alpine

Container that can build single file Python apps with PyInstaller for Alpine Linux.

Alpine uses musl instead of glibc. The PyInstaller bootloader for Linux 64 that comes with PyInstaller is made for glibc. This container image builds a bootloader with musl.

This container image also provides a clean way to build PyInstaller apps in an isolated environment.

This setup works with Podman and Docker. The examples below use podman.

Usage

Building A PyInstaller Package

To build a Python package, create a container with your source mounted as a volume at /src:

podman run --rm \
    -v "${PWD}:/src" \
    hub.datalad.org/forgejo/pyinstaller \
    --noconfirm \
    --onefile \
    --log-level DEBUG \
    --clean \
    example.py

If a requirements.txt file is found in your source directory, the requirements will automatically be installed with pip.

This will output a built app to the dist sub-directory in your source directory. The app can be ran on an Alpine OS:

./dist/example

Encrypting Your App

You can use PyInstaller to obfuscate your source with encryption. To use a specific key, pass a 16 character string with the --key {key-string} parameter. A non-standard feature of this container is that you can use --random-key to use a random key:

podman run --rm \
    -v "${PWD}:/src" \
    hub.datalad.org/forgejo/pyinstaller \
    --onefile \
    --random-key \
    --clean \
    example.py

Reproducible Build

If you want a Reproducible Build when your source has not changed, you can pass a PYTHONHASHSEED env var for consistent randomization for internal data structures:

podman run --rm \
    -v "${PWD}:/src" \
    -e PYTHONHASHSEED=42 \
    hub.datalad.org/forgejo/pyinstaller \
    --onefile \
    --clean \
    example.py

cksum dist/example | awk '{print $1}'