Leigh K
Leigh K

Reputation: 603

Issues compiling GTK software in MSYS2/MinGW with PyInstaller

I had a year old version of MSYS2/MinGW that was using PyInstaller with Python3.7 to compile a C GTK application in Windows (python was needed for a plotting script) and everything worked fine until pacman refused to update any packages since I kept getting the error:

error: hook /usr/share/libalpm/hooks/mingw-w64-x84_64-gtk-query-immodules-3.0.hook line 2: invalid value Path
error: hook /usr/share/libalpm/hooks/mingw-w64-x84_64-gtk-update-icon-cache.hook line 2: invalid value Path
Errors occurred, no packages were upgraded.

I looked those up and the general response for it is: "The issue is usually provoked when you don't maintain your system at regular intervals - and I am not thinking yearly - because such neglect will often result in similar problems. The issue stems from a change in pacman code..."

So I decided to start from a fresh MSYS2 install and used the following lines from both an MSYS2 shell and a MinGW-x64 shell, and each of them fails at a different point:

pacman -Syu
pacman -Su
pacman -S nano
pacman -S mingw-w64-i686-gtk3
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gtk3 mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-gobject
pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake
pacman -S python3-pip
pacman -S mingw-w64-x86_64-python3-pip
pacman -S msys2-devel
pacman -S mingw-w64-x86_64-glade
pacman -S mingw-w64-x86_64-gobject-introspection
pip install pyinstaller

In the case of the MSYS2 shell, the pip install pyinstaller fails with:

# pip install pyinstaller
Collecting pyinstaller
  Using cached PyInstaller-3.6.tar.gz (3.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3.exe /usr/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpd9hk1ekp
       cwd: /tmp/pip-install-ouq11vnr/pyinstaller
  Complete output (1 lines):
  Your platform is not yet supported. Please define constant PYDYLIB_NAMES for your platform.

An internet search shows this issue coming up on the github page for PyInstaller and a post here, neither of which were remotely enlightening:

https://github.com/pyinstaller/pyinstaller/issues/4542

How to fix: PyInstaller in MSYS2 MinGW 'Your platform is not yet supported'

In the case of a MinGW shell, I can install everything fine, but I cannot compile the C code because I get the error:

fatal error: sys/wait.h: No such file or directory
    7 | #include <sys/wait.h>
      |          ^~~~~~~~~~~~
compilation terminated.

Which means that MinGW doesn't know where to look for this file. It is located in:

msys64/usr/include/sys

but I suppose that only works for an MSYS2 shell? And yet my year old MinGW shell will compile the C code without this error, but despite every effort (following the bash history for package installation for the working version, manually copying over package folders, on and on) I continue to come up against this error. Just copying the folder above into the MinGW include folder results in further issues and is clearly sloppy. I want a repeatable way to get this to work, and I have repeated the process outlined above on several computers and have got the exact same result every time - so I expect anyone starting with a fresh MSYS2 install will run up against the same problems. Any help in getting this to run would be very much appreciated as I am getting frustrated with all of the dead ends.

Upvotes: 2

Views: 1353

Answers (2)

Leigh K
Leigh K

Reputation: 603

I was finally able to get this figured out. The first thing to know is that the initial compiling must be done in the MSYS2 shell. Once you successfully compile it in the MSYS2 shell, you can then compile in the MINGW shell without issue. I am not sure why that is so, but I anticipated it would be the case.

I solved the PyInstaller issue by downloading Python 3.7 from http://repo.msys2.org/ and installing it using:

pacman -U python-3.7.2-1-x86_64.pkg.tar

I also needed Python 3.7 installed in Windows, and the path edited in my .bashrc file:

export PYTHON_HOME=C:\\Users\\Leigh\\AppData\\Local\\Programs\\Python\\Python37
export PATH="$PYTHON_HOME:$PYTHON_HOME\\Scripts:$PATH"

I am not sure if PyInstaller is compatible with Python 3.8 yet. I posted an issue to their GitHub page, and it is here for reference in case it is resolved:

https://github.com/pyinstaller/pyinstaller/issues/4996

PyInstaller then worked, but I was met with another issue that I posted to Stack Overflow, but figured out as well. That is here:

MSYS2 gcc fatal error in cc1.exe: cygheap base mismatch detected

After that issue was resolved I could compile my program in MSYS2. Switching over to a MINGW shell, I found that it now compiled there as well.

Upvotes: 2

Brecht Sanders
Brecht Sanders

Reputation: 7287

sys/wait.h isn't there in MinGW, but you can use the one from: https://github.com/win32ports/sys_wait_h

Upvotes: 1

Related Questions