Skip to content

engineervix/docker-pyinstaller

 
 

Repository files navigation

PyInstaller Docker Images

This is a fork of cdrx/docker-pyinstaller, with the following changes:

  • change Ubuntu base images from 12.04/14.04/16.04 to 18.04/20.04
  • change PyInstaller version from 3.6 to 4.0 for Python 3
  • change to latest Python 3.7.X and 2.7.X releases (as of October 4th, 2020)
  • change OpenSSL from 1.0.2 to 1.1.1
  • change winetricks win7 to winetricks win10
  • change WINE_VERSION=winehq-staging to WINE_VERSION=winehq-stable
  • other minor modifications

engineervix/pyinstaller-linux and engineervix/pyinstaller-windows are a pair of Docker containers to ease compiling Python applications to binaries / exe files.

Current PyInstaller version used: 4.0 (for Python 3) and 3.6 (for Python 2).

Tags

engineervix/pyinstaller-linux and engineervix/pyinstaller-windows both have two tags, :python2 and :python3 which you can use depending on the requirements of your project. :latest points to :python3

The :python2 tags run Python 2.7.

The :python3 tag runs Python 3.7.

Usage

There are two containers, one for Linux and one for Windows builds. The Windows builder runs Wine inside Ubuntu to emulate Windows in Docker.

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 -v "$(pwd):/src/" engineervix/pyinstaller-windows

will build your PyInstaller project into dist/windows/. The .exe file will have the same name as your .spec file.

docker run -v "$(pwd):/src/" engineervix/pyinstaller-linux

will build your PyInstaller project into dist/linux/. The binary will have the same name as your .spec file.

How do I install system libraries or dependencies that my Python packages need?

You'll need to supply a custom command to Docker to install system pacakges. Something like:

docker run -v "$(pwd):/src/" --entrypoint /bin/sh engineervix/pyinstaller-linux -c "apt-get update -y && apt-get install -y wget && /entrypoint.sh"

Replace wget with the dependencies / package(s) you need to install.

How do I generate a .spec file?

docker run -v "$(pwd):/src/" engineervix/pyinstaller-linux "pyinstaller your-script.py"

will generate a spec file for your-script.py in your current working directory. See the PyInstaller docs for more information.

How do I change the PyInstaller version used?

Add pyinstaller=X.Y.Z to your requirements.txt (where X.Y.Z represents the version).

Is it possible to use a package mirror?

Yes, by supplying the PYPI_URL and PYPI_INDEX_URL environment variables that point to your PyPi mirror.

Known Issues

None

License

MIT

About

PyInstaller for Linux and Windows inside Docker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%