batonogov/pyinstaller-linux, batonogov/pyinstaller-windows and batonogov/pyinstaller-osx (Experimental) are a trio of Docker/Podman containers to ease compiling Python applications to binaries / exe files.
Images available on multiple container registry:
batonogov/pyinstaller-windows
/ docker.io/batonogov/pyinstaller-windows
batonogov/pyinstaller-linux
/ docker.io/batonogov/pyinstaller-linux
batonogov/pyinstaller-osx
/ docker.io/batonogov/pyinstaller-osx
ghcr.io/batonogov/pyinstaller-windows
ghcr.io/batonogov/pyinstaller-linux
ghcr.io/batonogov/pyinstaller-osx
For linux images have slim and bullseye/bookworm version will ensure better compatibility.
-slim
-slim-bookworm
-slim-bullseye
There are three containers, one for Linux
and one for Windows
and one for osx
builds.
The Windows builder runs Wine
inside Ubuntu to emulate Windows in Docker.
The osx builder used sickcodes/docker-osx
base image.
To build your application, you need to mount your source code into the /src/
volume.
The source code directory should have your .spec
file that PyInstaller generates. If you don't have one, you'll need to run PyInstaller once locally to generate it.
If the src
folder has a requirements.txt
file, the packages will be installed into the environment before PyInstaller runs.
For example, in the folder that has your source code, .spec
file and requirements.txt
:
docker run \
--volume "$(pwd):/src/" \
batonogov/pyinstaller-windows:latest
will build your PyInstaller project into dist/
. The .exe
file will have the same name as your .spec
file.
docker run \
--volume "$(pwd):/src/" \
batonogov/pyinstaller-linux:latest
will build your PyInstaller project into dist/
. The binary will have the same name as your .spec
file.
You'll need to pass an environment variable called SPECFILE
with the path (relative or absoulte) to your spec file, like so:
docker run \
--volume "$(pwd):/src/" \
--env SPECFILE=./main-nogui.spec \
batonogov/pyinstaller-linux:latest
This will build the executable from the spec file main-nogui.spec
.
You'll need to supply a custom command to Docker to install system pacakges. Something like:
docker run \
--volume "$(pwd):/src/" \
--entrypoint /bin/sh batonogov/pyinstaller-linux:latest \
-c "apt update -y && apt install -y wget && /entrypoint.sh"
Replace wget
with the dependencies / package(s) you need to install.
docker run \
--volume "$(pwd):/src/" \
batonogov/pyinstaller-linux:latest \
"pyinstaller --onefile your-script.py"
will generate a spec
file for your-script.py
in your current working directory. See the PyInstaller docs for more information.
Add pyinstaller==6.9.0
to your requirements.txt
.
Yes, by supplying the PYPI_URL
and PYPI_INDEX_URL
environment variables that point to your PyPi mirror.
See example for GitLab CI.
windows_bin:
stage: deploy
image:
name: batonogov/pyinstaller-windows:latest
entrypoint: ['']
script:
- echo "Creating Windows artifact"
- pip install -r ./test/requirements.txt
- cd ./test && pyinstaller --onefile main.py
- cp ./dist/*.exe ../
rules:
- when: always
artifacts:
paths:
- '*.exe'
when: always
expire_in: 2 week
Bitbucket doesn't support custom entrypoints, so we need to manually call it. Otherwise the setup is similar to what you would do with GitLab CI.
pipelines:
default:
- step:
name: Build Windows executable
image: batonogov/pyinstaller-windows:latest
artifacts:
paths:
- *.exe
script:
- echo "Creating Windows artifact"
- SPECFILE="$BITBUCKET_CLONE_DIR/sparvio-logger-bootstrap.spec" WORKDIR="$BITBUCKET_CLONE_DIR" bash /entrypoint.sh
- pip install -r ./test/requirements.txt
- cd ./test && pyinstaller --onefile main.py
- cp ./dist/*.exe ../
Outdated Microsoft C++ Build Tools
Now release information will be here.
Release History
MIT