Giter VIP home page Giter VIP logo

docker-pyinstaller's Introduction

PyInstaller Docker Images

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

Current PyInstaller version used: 3.6.

Tags

cdrx/pyinstaller-linux and cdrx/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/" cdrx/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/" cdrx/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 cdrx/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/" cdrx/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=3.1.1 to your requirements.txt.

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

History

[1.0] - 2016-08-26

First release, works.

[1.1] - 2016-12-13

Added Python 3.4 on Windows, thanks to @bmustiata

[1.2] - 2016-12-13

Added Python 3.5 on Windows, thanks (again) to @bmustiata

[1.3] - 2017-01-23

Upgraded PyInstaller to version 3.2.1. Thanks to @bmustiata for contributing:

  • Custom PyPi URLs
  • No longer need to supply a requirements.txt file if your project doesn't need it
  • PyInstaller can be called directly, for e.g to generate a spec file

[1.4] - 2017-01-26

Fixed bug with concatenated commands in entrypoint arguments, thanks to @alph4

[1.5] - 2017-09-29

Changed the default PyInstaller version to 3.3

[1.6] - 2017-11-06

Added Python 3.6 on Windows, thanks to @jameshilliard

[1.7] - 2018-10-02

Bumped Python version to 3.6 on Linux, thank you @itouch5000

[1.8] - 2019-01-15

Build using an older version of glibc to improve compatibility, thank you @itouch5000 Updated PyInstaller to version 3.4

[1.9] - 2020-01-14

Added a 32bit package, thank you @danielguardicore Updated PyInstaller to version 3.6

License

MIT

docker-pyinstaller's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-pyinstaller's Issues

pypi URL configuration

When running in CI environments, the system shouldn't try to fetch it's dependencies from the Internet, but allow to use configured custom URLs.

pyinstaller: error: the following arguments are required: scriptname

I am running this on a Travis CI instance. I get the following result:

if [[ "$TRAVIS_OS_NAME" = "docker" ]]; then docker pull cdrx/pyinstaller-linux; fi
Using default tag: latest
latest: Pulling from cdrx/pyinstaller-linux
Status: Downloaded newer image for cdrx/pyinstaller-linux:latest
if [[ "$TRAVIS_OS_NAME" = "docker" ]]; then docker run -v "$(pwd)/src:/src/" cdrx/pyinstaller-linux pyinstaller stacoan.py; fi
Collecting yattag (from -r requirements.txt (line 1))
  Downloading yattag-1.10.0.tar.gz
Building wheels for collected packages: yattag
  Running setup.py bdist_wheel for yattag: started
  Running setup.py bdist_wheel for yattag: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/a2/23/18/c17e8653e0af1b67d72c02f2d48451d031b9ed889c210272de
Successfully built yattag
Installing collected packages: yattag
Successfully installed yattag-1.10.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pyinstaller stacoan.py
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
                   [--add-data <SRC;DEST or SRC:DEST>]
                   [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
                   [--hidden-import MODULENAME]
                   [--additional-hooks-dir HOOKSPATH]
                   [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
                   [--key KEY] [-d] [-s] [--noupx] [-c] [-w]
                   [-i <FILE.ico or FILE.exe,ID or FILE.icns>]
                   [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
                   [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
                   [--win-no-prefer-redirects]
                   [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                   [--runtime-tmpdir PATH] [--distpath DIR]
                   [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a]
                   [--clean] [--log-level LEVEL]
                   scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname

(full travis.yml file here: https://github.com/vincentcox/StaCoAn/blob/8f8178b16c21e8af2550f85dc2631826abecd21b/.travis.yml)
https://travis-ci.org/vincentcox/StaCoAn/jobs/347456280

Any idea what is causing this?

I'm really happy that I found your project because I am wasting the past days on finding a way to compile my application for windows on a Linux environment. Pywin32 broke my previous build construction 😒
(mhammond/pywin32#1172 (comment))

Cannot run Image

I cannot seem to run this image when I use both:
docker run cdrx/pyinstaller-linux:python2
docker run cdrx/pyinstaller-windows:python2
I tried this even after switching to a linux container and got the same error below
The error I get is image operating system "linux" cannot be used

Any help would be appreciated!

Multiprocessing not working after compiling

I am working on a project where I need to do a pretty long number of web requests an wait for their answers. In order to achieve that I am using the multiprocessing lib:

import multiprocessing

...
print('===> Running multiprocess...')
with multiprocessing.Pool(multiprocessing.cpu_count()) as p:
        similar_result = p.map(func, list)

When I try to run the script on Python it works perfectly. But when I compile it to an EXE using your Docker it throws me this error:

===> Running multiprocess...
02ca:fixme:reg:GetMaximumProcessorCount semi-stub, returning 8
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ca:fixme:ntdll:server_get_file_info Unsupported info class e
02ef:fixme:ntdll:server_get_file_info Unsupported info class e
02f1:fixme:ntdll:server_get_file_info Unsupported info class e
02f3:fixme:ntdll:server_get_file_info Unsupported info class e
02f5:fixme:ntdll:server_get_file_info Unsupported info class e
02f7:fixme:ntdll:server_get_file_info Unsupported info class e
02f9:fixme:ntdll:server_get_file_info Unsupported info class e
02fb:fixme:ntdll:server_get_file_info Unsupported info class e

I've already inserted the multiprocessing.freeze_support() as this recipe suggests:

if __name__ == '__main__':
    multiprocessing.freeze_support() # Added to multiprocessing works in Pyinstaller
    run()

But it is still not working.
I think it is something related to the fact that your Docker container uses Wine to compile it. Can you help me?

Linux py3 build fails

Downloading Python-3.7.5.tar.xz...
-> https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz
Installing Python-3.7.5...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
BUILD FAILED (Ubuntu 12.04 using python-build 20180424)```

Fatal Python error: Py_Initialize: can't initialize sys standard streams

Hello,

I'm trying to use this container to build a windows application inside a jenkins pipeline.

However, I'm getting an error while execution:

+ pyinstaller start.spec
0027:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0027:err:winediag:nodrv_CreateWindow Make sure that your X server is running and that $DISPLAY is set correctly.
0027:err:ole:apartment_createwindowifneeded CreateWindow failed with error 0
0027:err:ole:apartment_createwindowifneeded CreateWindow failed with error 0
0027:err:ole:apartment_createwindowifneeded CreateWindow failed with error 0
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [WinError 6] Invalid handle
Current thread 0x0000002f (most recent call first):

sometimes the outpus is only

Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [WinError 6] Invalid handle
Current thread 0x0000002b (most recent call first):

This is my pipeline stage:

stage('Deliver') {
  agent {
    docker {
      image 'cdrx/pyinstaller-windows:python3'
      args '--entrypoint="" -u root:root -v ${PWD}:/src -w /src'
    }
  }
  steps {
    sh 'pyinstaller start.spec'
  }
}

Using wine directly from within the pipeline results in a similar error:

+ wine /wine/drive_c/Python36/Scripts/pyinstaller.exe start.spec
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [WinError 6] Invalid handle
Current thread 0x0000002c (most recent call first):

Could you tell me please if this is a bug or is there someting I'm missing?

Thanks and best regards

Pre-install git to wine (feature request)

Hi,

Thanks for these really useful containers.

Would it be possible to install git into wine to support the installation of git repos via pip install?
E.g. using the windows container, I'm getting the following error
Error [WinError 2] File not found while executing command git clone -q ssh://git@...

Thanks

Build doesn't include build directory in module path

Aside from the issue #25 I was having problems building Linux and Windows binaries. It seems docker-pyinstaller no longer includes /src in the Python module path. So to get my builds to see the module folder in the directory that the main code was in I had to use docker run -e PYTHONPATH=/src ... so the build process could find my modules. This hadn't been a problem in a prior version to my knowledge.

Unable to get dependencies directly from GitHub

My requirement.txt file contains direct links to dependencies:

https://github.com/ralph-group/pymeasure
numpy==1.16.2
...

At the launch of the docker-pyinstaller-windows container I get an error that the archive format is not recognized.

I also tried with the GIt format :
-e git+https://github.com/ralph-group/pymeasure.git#egg=pymeasure
but I get another error that says the git command is not recognized.
Can you advise me if there is a solution to use dependencies from GitHub? Thank you in advance!

Gor

Exe outputs: "Z:\src\.gitignore could not be extracted!"

When running the compiled exe in a Windows command prompt, the output is:

Z:\src\.gitignore could not be extracted!

The command used to build is:

~/Trumpocalypse/UI$ docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows:python2 "pyinstaller --onefile Trumpocalypse.py".

Where Trumpocalypse.py resides in the folder ~/Trumpocalypse/UI/.

There is no requirements file used. Could this be an issue? Requirements are: pygame 1.9.1 and python 2.7.

Built binaries won't run on Ubuntu 16.04 LTS

The main reason I used this docker image was to build PyInstaller binaries for a Ubuntu 16.04 on my Ubuntu 18.04. That worked good until the last change, since the base image was Ubuntu 16.04 so the binary was built on the same platform as my target platform.

With the current image, building the project and trying to run on an Ubuntu 16.04 system following error occurs:

[27488] Error loading Python lib '/etc/job2/temp/_MEIgCEd5f/libpython3.6m.so.1.0': dlopen: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /etc/job2/temp/_MEIgCEd5f/libpython3.6m.so.1.0)

I used the python3 Linux image.

I propose adding more tags for different Linux distros so that you can choose on which platform you want to build. I have currently solved my problem by modifiying the Dockerfile locally to use the Ubuntu 16.04 base again.

PermissionError: [WinError 5]

I got error after running:

docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows

Error output:

Installing collected packages: appdirs, cached-property, certifi, chardet, colorama, defusedxml, greenlet, gevent, idna, isodate, lxml, pip, pytz, urllib3, requests, requests-toolbelt, setuptools, six, wheel, zeep
  Running setup.py install for isodate: started
err:winediag:SECUR32_initNTLMSP ntlm_auth was not found or is outdated. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.
    Running setup.py install for isodate: finished with status 'done'
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
Exception:
Traceback (most recent call last):
  File "c:\Python35\lib\shutil.py", line 381, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access denied: 'C:\\users\\root\\Temp\\pip-vdu80sk3-uninstall\\python35\\scripts\\pip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Python35\lib\site-packages\pip\basecommand.py", line 209, in main
    logger.critical(
  File "c:\Python35\lib\site-packages\pip\commands\install.py", line 317, in run
  File "c:\Python35\lib\site-packages\pip\req\req_set.py", line 743, in install
  File "c:\Python35\lib\site-packages\pip\req\req_install.py", line 759, in commit_uninstall
    self.uninstalled.rollback()
  File "c:\Python35\lib\site-packages\pip\req\req_uninstall.py", line 142, in commit
    rmtree(self.save_dir)
  File "c:\Python35\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "c:\Python35\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "c:\Python35\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "c:\Python35\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
    raise value
  File "c:\Python35\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "c:\Python35\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "c:\Python35\lib\shutil.py", line 488, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\Python35\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\Python35\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\Python35\lib\shutil.py", line 383, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "c:\Python35\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 5] Access denied: 'C:\\users\\root\\Temp\\pip-vdu80sk3-uninstall\\python35\\scripts\\pip.exe'

My requirements:

linux docker not working w/ python 3.7.2

If you set python version to 3.7.2 the linux docker build fails.

Reproducible steps:

  1. change to 'ARG PYTHON_VERSION=3.7.2' in linux/py3/Dockerfile
  2. docker build -t test .
  3. build fails

last lines of build output:

+++ export PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export PYENV_SHELL=bash
+++ PYENV_SHELL=bash
+++ source /root/.pyenv/libexec/../completions/pyenv.bash
++++ complete -F _pyenv pyenv
+++ command pyenv rehash

  • PYTHON_CONFIGURE_OPTS=--enable-shared
  • pyenv install 3.7.3
  • local command
  • command=install
  • '[' 2 -gt 0 ']'
  • shift
  • case "$command" in
  • command pyenv install 3.7.3
  • pyenv install 3.7.3
    Downloading Python-3.7.3.tar.xz...
    -> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
    Installing Python-3.7.3...

BUILD FAILED (Ubuntu 12.04 using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20190516213904.3706
Results logged to /tmp/python-build.20190516213904.3706.log

Last 10 log lines:
File "/tmp/tmpnohsr1i1/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 12, in
File "/tmp/tmpnohsr1i1/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/init.py", line 6, in
File "/tmp/tmpnohsr1i1/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/completion.py", line 6, in
File "/tmp/tmpnohsr1i1/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 20, in
File "/tmp/tmpnohsr1i1/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 37, in
File "/tmp/tmpnohsr1i1/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in
File "/tmp/python-build.20190516213904.3706/Python-3.7.3/Lib/ctypes/init.py", line 7, in
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
make: *** [install] Error 1

GitLab's CI and --onefile option

I have a pipeline set at GitLab to build Linux and Windows binaries.

My .gitlab-ci.yml looks like this:

    image: docker:stable

    variables:
    BASE_IMAGE: cdrx/pyinstaller
    IMAGE_TAG: python3

    services:
    - docker:dind

    .build: &build
    script:
        - docker run --rm -v "$(pwd):/src/" ${BASE_IMAGE}-${TARGET_OS}:${IMAGE_TAG} "pyinstaller --onefile myScript.py"
    artifacts:
        paths:
        - dist/myScript.py/

    build-windows:
    <<: *build
    variables:
        TARGET_OS: windows

    build-linux:
    <<: *build
    variables:
        TARGET_OS: linux

However, after finishing the job it says that there are no files to upload:

 [....]
 6674 INFO: checking PYZ
 6675 INFO: Building PYZ because PYZ-00.toc is non existent
 6675 INFO: Building PYZ (ZlibArchive) /src/build/myScript/PYZ-00.pyz
 7185 INFO: Building PYZ (ZlibArchive) /src/build/myScript/PYZ-00.pyz completed successfully.
 7194 INFO: checking PKG
 7195 INFO: Building PKG because PKG-00.toc is non existent
 7195 INFO: Building PKG (CArchive) PKG-00.pkg
 17274 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
 17305 INFO: Bootloader /root/.pyenv/versions/3.7.5/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-64bit/run
 17306 INFO: checking EXE
 17307 INFO: Building EXE because EXE-00.toc is non existent
 17307 INFO: Building EXE from EXE-00.toc
 17308 INFO: Appending archive to ELF section in EXE /src/dist/myScript
 17502 INFO: Building EXE from EXE-00.toc completed successfully.
Uploading artifacts...
 WARNING: dist/myScript.py/: no matching files          
 ERROR: No files to upload                          
 Job succeeded

And if I simply remove that --onefile option, then everything works just fine, a whole bundle uploads (and works) OK.

What am I missing? :)

Creation of .spec file

Hi,
I wanted to create an .exe for a python application. I followed the instruction to create a .spec file first, so I ran docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows pyinstaller <script_name>.py as suggested in the README, but I got the following output:

pyinstaller <script_name>.py
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
                   [--add-data <SRC;DEST or SRC:DEST>]
                   [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
                   [--hidden-import MODULENAME]
                   [--additional-hooks-dir HOOKSPATH]
                   [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
                   [--key KEY] [-d] [-s] [--noupx] [-c] [-w]
                   [-i <FILE.ico or FILE.exe,ID or FILE.icns>]
                   [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
                   [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
                   [--win-no-prefer-redirects]
                   [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                   [--runtime-tmpdir PATH] [--distpath DIR]
                   [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a]
                   [--clean] [--log-level LEVEL]
                   scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname

I then got inside the container and ran pyinstaller --onefile <script_name>.py.
Then, once the .spec file was generated, I ran docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows to create the exe. When I then launch the executable, something seems to be missing.
I have also tried to run the installer withouth the --onefile option but I still get an executable which breaks.

Would you have any suggestions, especially around the creation of the .spec file? As running it in a container shouldn't give any error, as everything that is needed is there.

Thank you,
MIchela

Locally built docker image has wine error

wine: '/tmp/.wine-0/server-fd04-1601bf9/socket' is not a socket

It seems that I have to run wineserver first, then it will work. any idea why? Doesn't seem to be the case on the one distributed on docker hub.

sqlite json1 extension

Hi, I'm using peewee and a sqlite database with the json1 extension. On both a normal windows install as well as on my linux machine, sqlite out of the box has the json1 extension enabled.

When I however check on the python executable in the docker image it does not have this extension enabled and thus the build exe does not work correctly. Do you have any idea how I can do this in wine ?

How to create win32 application?

I have been using your image and pyinstaller for a while now, and I love it πŸ˜„ !
However, for a current project I want to generate a 32-bit application for an old Windows XP. By default (or design?) the pyinstaller-windows image generates a x86_64 executable. Is it possible to generate a 32-bit application as well?

Thanks!

Here's my .spec file

# -*- mode: python -*-

block_cipher = None

a = Analysis(['GUI.py'],
             pathex=[],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='DataUploader',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )

And docker run command I currently use within the project folder:

$ docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows

Build process broken with Ubuntu 16.04 as a base

Ubuntu 16.04 is no longer viable as a base for these images. The apt-get command will install nothing as the package servers for that version of Ubuntu seems to be gone now.

I was able to fix this locally for Linux/Python 3 replacing FROM ubuntu:16.04 with FROM python:3.6-stretch and removing python3 and libmysqlclient-dev from the apt-get call in the Dockerfile. This produced an image that was 935MB and produced binaries that worked fine on Ubuntu 17.10.

I also tried the same setup but with FROM python:3.6-slim-stretch that created a Docker image that was 491MB. It's binaries also worked on Ubuntu 17.10.

Then I tried FROM python:3.6-alpine and replacing the original apt-get calls with apk add --update-cache python3-dev git. This left me with a Docker image that was 199MB and was able to produce binaries that worked on Ubuntu 17.10 as well.

For the Windows 64-bit/Python 3 Dockerfile I could not find success until I used FROM ubuntu:17.10 and added gpg-agent, and rename to the apt-get call. This produced a Docker image that was 1.15GB. I didn't get around to testing other bases for the image.

None of these have been extensively tested. So I didn't create a Pull Request. I hope this issue and info helps. πŸ˜ƒ

Optional support for UPX

Add the UPX package to the Dockerfile for both Linux containers, allowing users to define spec files that use UPX for packing the resulting file without complicating their docker invocation.

Error loading Python DLL python35.dll

I get following error on Windows

Error loading Python DLL: C:\Users\ADMINI~1\AppData\Local\Temp\_MEI19602\python35.dll (error code 998)

I have seen something similar at git pyinstaller project, but no progress since months. Any ideas to fix the problem?

Lower GLIBC version

The current version of ubuntu used for the pyinstaller py3 image is not old enough to create binaries that run under CentOS 6.

Can we switch the base image to CentOS 6 instead of ubuntu 12.04?

Has something changed since the Jenkins tutorial?

I'm following these instructions: https://jenkins.io/doc/tutorials/build-a-python-app-with-pyinstaller/ with the difference being that I am using the python3 instead of python2 and, obviously that the name of my python file is different.

You can see at: https://github.com/djotaku/ELDonationTracker/blob/devel/JenkinsFile

The error I'm getting is:

+ pyinstaller --onefile extralifedonations.py

/var/jenkins_home/workspace/extralifedonationtracker@tmp/durable-38d45fbf/script.sh: 1: /var/jenkins_home/workspace/extralifedonationtracker@tmp/durable-38d45fbf/script.sh: pyinstaller: not found

script returned exit code 127

Has something changed since they wrote that tutorial? Or is something different with Py3 or something?

Thanks!

.python-version file overrides container installed version

When mounting a folder containing a .python-version file in /src/ directory, it crash because the version specified in the project file is not found in the container.

As a workaround, the container should be executed with the PYENV_VERSION environnement variable matching version from the container.

docker run -v "$(pwd):/src/" -e PYENV_VERSION=3.6.6 cdrx/pyinstaller-linux

Not clear which one should I choose to build

If I am working on linux platform and would like to build an exe file for windows (use linux to generate windows exe file). Which one shall I choose, the one with β€˜linux' as post-fix or with 'win32/64' as post-fix?

OSError: [WinError 123] Invalid name: '/tmp\\*'

Hi,

After I pulling the image from docker hub and running the command docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows, I got the error OSError: [WinError 123] Invalid name: '/tmp\\*'. I'm using Mac OS. Any idea on this? Thanks!

PyQt5 (required package) download failure

Hi,

I am trying to build an exe from docker-pyinstaller. And my software use PyQt5, as it is required, i have added PyQt5==5.9.2 in requirements.txt and when i am running pyinstaller to generate the exe, i have this error:
read tcp 192.168.99.1:52422->192.168.99.100:2376: wsarecv: A connection attempt
failed because the connected party did not properly respond after a period of ti
me, or established connection failed because connected host has failed to respond.

i am using this command:

$ docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows "pyinstaller --onefile --windowed run_GUI.py"

Regards,

Parallel builds collide in resulting file

If we run two containers at the same time from the same source dir, they will overwrite the resulting file.
Entrypoint.sh should distinguish and output to python3/linux/whatever and python2/linux/whatever, and as appropriate to the other OSes/versions

This can happen if we run python3 and python2 at the same time

pipenv support

Hello, First of all I am really thankful for the project. I was about to crazy and about to build my own version of docker.
( It seems coexistence of Python2 and Python3 within Windows makes build environment unstable or add side effect something I don't even know what causes problem; I must use Python2 for another build tools depending on it which not even using Python at all, and for Python development we now must use Python3 because Python2 is now deprecated. It is horrible )

Anyway, I think it is really good to support pipenv, as pipenv seems official and very mature, reasonable tool we can use in Python dev.
Just as this project already has support for detection of requirements.txt file, so does Pipfile can make this things through.

I will test some things and send PR.

Windows version not working with jenkins - "wine is not owned by you"

Trying to use this to build a simple Python gui exe for windows on a Jenkins CI build - see JenkinsFile below. I get the error

wine: /wine is not owned by you

I can't see how I can work around this as it seems the jenkins user can't user the wine installation (owned by root?)

pipeline {
    agent none
	options {
        skipStagesAfterUnstable()
    }
    stages {
        stage('Build') { 
	    agent {
                docker {
                    image 'python:2-alpine' 
		}
	    }
            steps {
                sh 'python -m py_compile client/python-client/modelportfolio/ModelPortfolioMain.py client/python-client/modelportfolio/restfulAPI.py client/python-client/modelportfolio/Utils.py' 
            }
        }
	stage('Deliver') {
            agent {
                docker {
                    image 'cdrx/pyinstaller-windows:latest'
                }
            }
            steps {
                sh 'pyinstaller --onefile client/python-client/modelportfolio/ModelPortfolioMain.py'
            }
            post {
                success {
                    archiveArtifacts 'dist/ModelPortfolioMain'
                }
            }
        }
    }
}

Consider using Docker tags for versions

Many popular Docker images use tags for versioning their images, e.g. debian:8.2. In fact, I think versioning is the main purpose of tags.

However, there are lots of projects that seem to use them instead as sub-projects, e.g. cdrx/pyinstaller-linux:python2 and cdrx/pyinstaller-linux:python3`.

My suggestion would be to change how you publish your Docker images, e.g.:

  • cdrx/pyinstaller-linux-py2:1.0
  • cdrx/pyinstaller-linux-py3:1.0

In this way, one would be able to pin to a specific version if needed. Cheers!

Support for py32/py64

Currently the docker images are 32bit and to get a 64b pyinstaller file I need to fork and build my own docker file.

Error: Permission denied

When attempting to run the following command:

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

I received the following errors:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
/root/.pyenv/bin/pyenv: line 87: cd: /src: Permission denied
bash: cd: /src: Permission denied

I use Fedora 29, this is my operation system:

Linux localhost.localdomain 4.20.13-200.fc29.x86_64 #1 SMP Wed Feb 27 19:42:55 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Multiple .spec files

My project has multiple .spec files. Is there an easy way to specify which one you want docker-pyinstaller to use?

Linux image for Python3 not running on GitLab CI Runner

Enviroment

GitLab CI Runner in Docker mode with bash shell and current cdrx/pyinstaller-linux:python3 image.

Problem description:

Some CI servers like the current GitLab CI Runners will execute scripts in docker containers in a non-interactive way. In this mode the .bashrc will not get executed which is discussed in detail in this StackExchange thread. Therefore the changes added to the .bashrc in the current Dockerfile for the linux python3 image are ignored. This results in errors like: "pip command not found", because obviously the changes to $PATH are ignored...

Problem delimitation:

I did not explicitly check how other CI solutions currently behave regarding interactive/non-interactive shell code execution.

Possible enhancement: Wrapper script

I found the wrapper script below quite useful, with this issue I would like to open up the discussion around maybe adding this script to the source. We could also add some support for a curl | sh approach for this script.

If people find this useful as well I would then create a pull request for this.

build.sh

#!/usr/bin/env sh
set -euo pipefail

function usage(){
  cat <<EOF
usage:
  ${SELF_NAME} [OPTIONS] -- [CMD]

  OPTIONS
    -h|--help                 Print this help.
    -v|--verbose              Enable verbose output.
    --linux                   Build for linux
    --windows                 Build for windows
    --python2                 Build using python2
    --python3                 Build using python3
    --print-dockerfile        Print dockerfile template and exit
    --dockerfile DOCKERFILE   Use the custom dockerfile under DOCKERFILE
    -t|--tty                  Allocate a pseudo-TTY.
    -i|--interactive          Keep STDIN open even if not attached.

  CMD: command to run inside the container

  Example Usage:

EOF
}

VERBOSE="${VERBOSE:-false}"

USER_ID="$(id -u)"
GROUP_ID="$(id -g)"
SRC_DIR="/src"

SELF="${0}"
SELF_NAME="$(basename "${SELF}")"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PROJECT_NAME="$(basename "${DIR}" | tr '[:upper:]' '[:lower:]')"

BUILD_FOR_OS="linux"
BUILD_FOR_PYTHON_VERSION="python3"

# Custom DOCKERFILE
read -r -d '' DOCKERFILE <<'EOF' || true
ARG from_image_name
ARG from_image_tag
FROM "${from_image_name}:${from_image_tag}"

#
# Install more packets
#
#RUN set -exu \
#  # update system
#  && apt-get update \
#  # install requirements
#  && apt-get install -y --no-install-recommends \
#    libgmp-dev
EOF

declare -a CMD=( "" )
declare -a ARGS=( "" )
while [ ${#} -gt 0 ]; do
  case "${1}" in
    -h|--help)
      usage
      exit 0
    ;;
    -t|--tty)
      ARGS+="--tty " && shift
    ;;
    -i|--interactive)
      ARGS+="--interactive " && shift
    ;;
    -ti|-it)
      shift
      ARGS+="--tty "
      ARGS+="--interactive "
    ;;
    -v|--verbose)
      VERBOSE=true && shift
    ;;
    --linux)
      BUILD_FOR_OS="linux" && shift
    ;;
    --windows)
      BUILD_FOR_OS="windows" && shift
    ;;
    --python2)
      BUILD_FOR_PYTHON_VERSION="python2" && shift
    ;;
    --python3)
      BUILD_FOR_PYTHON_VERSION="python3" && shift
    ;;
    --print-dockerfile)
      echo "${DOCKERFILE}" && shift
      exit 0
    ;;
    --dockerfile)
      shift
      DOCKERFILE="$(cat "${1}")" && shift
    ;;
    --)
      shift
      CMD="${@}"
      break
    ;;
    *)
      CMD="${@}"
      break
    ;;
  esac
done

if [ "${VERBOSE}" = true ]; then
  set -x
fi

from_image_name="cdrx/pyinstaller-${BUILD_FOR_OS}"
from_image_tag="${BUILD_FOR_PYTHON_VERSION}"
image_name="build-${PROJECT_NAME}-${BUILD_FOR_OS}"
image_tag="${BUILD_FOR_PYTHON_VERSION}"

(
  cd "${DIR}"

  echo "${DOCKERFILE}" \
  | docker \
      build \
      --build-arg=from_image_name="${from_image_name}" \
      --build-arg=from_image_tag="${from_image_tag}" \
      --tag "${image_name}:${image_tag}" \
      -

  docker run \
    --rm \
    --env "SRCDIR=${SRC_DIR}" \
    --mount type=bind,source="${DIR}",target=${SRC_DIR} \
    ${ARGS[@]} \
    "${image_name}:${image_tag}" "${CMD[@]}"
)

requitements txt with external dependencies cannot be satisfied

Hello,

First thank you for the great work! :)

Second, I have found a theoretical problem in your image.

I try to build wxpython based application with your images, and with Windows it works fine.
However, when I try to do the same, I have GTK missing error for the wxpython listed in the requirements.txt file.

You provided an example in the Readme.md how to overcome this, but it cannot be fixed with that.

The example you provided in the Readme.md actually not replaces the entrypoint, just passes it as an argument, which will be executed as the install step.

So if there is a third party dependency (wxpython->GTK3), there is no way to satisfy it till the time the requirements.txt processed.

I know two workaroud here:

  • rename the requirements.txt file and and use my renamed file during the install step, but just after I installed the dependcies in this same command
  • disable the entrypoint and call requirement installation in my on oreder

I consider both of them as a hack, and there should be some way to install third party dependencies before requirements.txt processed without rebuilding the image.

How to use UPX for EXE compression?

Hi,

Thanks for this work, it is pretty handy for Linux users. While the problem for me is that the EXE can be pretty large for a simple application, which takes 120 MB for a simple page.

I have noticed when running pyinstaller, a message shows that the UPX is currently not avaliable.

264 INFO: PyInstaller: 3.5
264 INFO: Python: 3.6.4
269 INFO: Platform: Windows-XP-5.1.2600
279 INFO: UPX is not available.

I am wondering is it possible to install it manually, or even to incorporate the UPX into the docker image.

Best,
Jian

Running Parameters to Docker Images

The docker images should be usable standalone, without requiring the installation of an initial pyinstaller for the initial creation of the *.spec files.

Getting Access denied on `.dist/windows`

I'm getting PermissionError: [WinError 5] Access denied: './dist/windows' when doing sudo docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows

Here is the last stack trace:

862 INFO: Python: 3.7.5
876 INFO: Platform: Windows-XP-5.1.2600
950 INFO: UPX is not available.
954 INFO: Removing temporary files and cleaning cache in C:\users\root\Application Data\pyinstaller
Traceback (most recent call last):
  File "c:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "c:\Python37\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\Python37\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 746, in build
    os.makedirs(pth)
  File "c:\Python37\lib\os.py", line 221, in makedirs
    mkdir(name, mode)
PermissionError: [WinError 5] Access denied: './dist/windows'

Strange temporary file error

docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows:python2
...
355 INFO: Removing temporary files and cleaning cache in C:\users\root\Application Data\pyinstaller
Traceback (most recent call last):
  File "C:\Python27\Scripts\pyinstaller-script.py", line 9, in <module>
    load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
  File "C:\Python27\lib\site-packages\PyInstaller\__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Python27\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Python27\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Python27\lib\site-packages\PyInstaller\building\build_main.py", line 691, in build
    os.makedirs(pth)
  File "C:\Python27\lib\os.py", line 157, in makedirs
    mkdir(name, mode)
WindowsError: [Error 123] Invalid name: '/tmp\\*'

Have you seen this before?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.