pywine icon indicating copy to clipboard operation
pywine copied to clipboard

Fail to found python dll since Python 3.12 (UPX issue)

Open Faduf opened this issue 1 year ago • 5 comments

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 using wine 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).

Faduf avatar Sep 12 '24 13:09 Faduf

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...)

TobiX avatar Sep 14 '24 23:09 TobiX

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

Faduf avatar Sep 17 '24 12:09 Faduf

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)

TobiX avatar Sep 17 '24 13:09 TobiX

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

Faduf avatar Sep 18 '24 11:09 Faduf

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

TobiX avatar Sep 18 '24 13:09 TobiX