webcomics / pywine

Docker image for Wine with Python
MIT License
90 stars 25 forks source link

Fail to found python dll since Python 3.12 #62

Open Faduf opened 1 week ago

Faduf commented 1 week ago

We are using the official pywine docker from dockerhub to generate .exe binaries with PyInstaller inside the docker. At the end of our script we have a check by usingwine generated_binary.exe -v to get the binary version. Since the update to Python 3.12, this command returns the following error :

[PYI-228:ERROR] Failed to load Python DLL 'C:\users\root\AppData\Local\Temp\_MEI2202\python312.dll'.
LoadLibrary: DLL initialization failed.

This can be reproduced with pywine:3.12 and pywine:latest (currently python 3.12.4).

TobiX commented 1 week ago

Hmm. I cannot reproduce this issue. Any non-standard mounts maybe? On which filesystem(s) is/are your docker storage directories? We already had horrible issues on WSL2 mounts (https://github.com/webcomics/pywine/issues/16#issuecomment-1565655777), but you should receive a big, fat warning with such a setup (at least when launching the container through the default entrypoint...)

Faduf commented 5 days ago

We have this on different Linux Debian 11 machines. The following docker run command is used :

docker run --rm --workdir=/tools -v $CI_PROJECT_DIR/tools:/tools --user $(id -u):$(id -g) tobix/pywine bash -xe $CI_JOB_NAME.sh

the script $CI_JOB_NAME.sh is used to install required python libraries, generate the .exe with PyInstaller and check the .exe sanity :

      . /opt/mkuserwineprefix
      export PYTHONDONTWRITEBYTECODE=1

      wine pip3 install -r /$PYREQ_PATH

      wine pyinstaller swupdate-client.py \
        --collect-submodules websockets \
        --workpath /tmp -F -y --clean

      wine pyinstaller swupdate-archiver/swupdate_archiver.py \
        --add-binary "/$CPIO_PATH/bin/*;." \
        --workpath /tmp -F -y --clean

      { echo "swupdate_archiver: \$(wine dist/swupdate_archiver.exe -v)"
        echo "swupdate-client: \$(wine dist/swupdate-client.exe -v)"
      }>versions.manifest
TobiX commented 5 days ago

Could you try with --noupx or just --upx-exclude python312.dll? Not sure what's the issue is with UPX, but it seems to conflict with Python 3.12 under wine...

(I'd suggest to disable UPX if you don't care that much about the final file size, since it often leads to false-positives with Anti-Virus software)

Faduf commented 4 days ago

Both solutions (--noupx or --upx-exclude python312.dll) solve the issue. The final file size increases a bit but it is acceptable.

TobiX commented 4 days ago

This seems similar to https://github.com/pyinstaller/pyinstaller/issues/1565 ... Strange that it only affects Wine...