Patches for sip / PyQt-builder for mingw cross-compilation of python bindings

Sandro Mani manisandro at gmail.com
Wed Sep 15 09:44:21 BST 2021


Hi

I maintain a mingw-python3 stack for Fedora which I also use to 
cross-compile SIP bindings to Windows.

Attached below are some changes I've applied to sip6/PyQt-builder (let 
me know if there is a better way to contribute these).

Thanks
Sandro

-------------

Patch to be applied to sip6: replaces two occurences of sys.platform 
with project.py_platform. sys.platform refers to the host platform, 
whereas it looks like py_platform will refer to the target platform. See 
also patch to PyQtBuilder below.

diff -rupN sip-6.1.1/sipbuild/buildable.py 
sip-6.1.1-new/sipbuild/buildable.py
--- sip-6.1.1/sipbuild/buildable.py    2021-06-09 11:59:54.000000000 +0200
+++ sip-6.1.1-new/sipbuild/buildable.py    2021-09-15 10:24:13.188849424 
+0200
@@ -146,7 +146,7 @@ class BuildableModule(BuildableFromSourc
      def get_module_extension(self):
          """ Return the filename extension that a module should have. """

-        if sys.platform == 'win32':
+        if self.project.py_platform == 'win32':
              return '.pyd'

          suffixes = importlib.machinery.EXTENSION_SUFFIXES
diff -rupN sip-6.1.1/sipbuild/builder.py sip-6.1.1-new/sipbuild/builder.py
--- sip-6.1.1/sipbuild/builder.py    2021-06-09 11:59:54.000000000 +0200
+++ sip-6.1.1-new/sipbuild/builder.py    2021-09-15 10:23:22.572824602 +0200
@@ -157,7 +157,7 @@ class Builder(AbstractBuilder):
                              LAST_SUPPORTED_MINOR + 1)]
              wheel_tag.append('.'.join(vtags))

-            wheel_tag.append('none' if sys.platform == 'win32' else 'abi3')
+            wheel_tag.append('none' if project.py_platform == 'win32' 
else 'abi3')
          else:
              major_minor = '{}{}'.format((sys.hexversion >> 24) & 0xff,
                      (sys.hexversion >> 16) & 0xff)

-------------

Patch to be applied to PyQt5-builder:

- Handle mingw in QMake xspec
- Fix detecting make on g++ host
- Also add -l<pylib_lib> to qmake pro to build extension

diff -rupN PyQt-builder-1.10.3/pyqtbuild/builder.py 
PyQt-builder-1.10.3-new/pyqtbuild/builder.py
--- PyQt-builder-1.10.3/pyqtbuild/builder.py    2021-05-13 
19:31:21.000000000 +0200
+++ PyQt-builder-1.10.3-new/pyqtbuild/builder.py    2021-09-15 
00:02:38.810536106 +0200
@@ -103,6 +103,8 @@ class QmakeBuilder(Builder):
                  py_platform = 'wasm'
              elif 'win32' in xspec:
                  py_platform = 'win32'
+            elif 'mingw-w64' in xspec:
+                py_platform = 'win32'
              else:
                  # Treat everything else as Linux.
                  py_platform = 'linux'
@@ -336,8 +338,8 @@ class QmakeBuilder(Builder):
          """ Return the name of a valid make program. """

          if self.project.py_platform == 'win32':
-            if self.spec == 'win32-g++':
-                make = 'mingw32-make'
+            if "g++" in self.spec:
+                make = 'make'
              else:
                  make = 'nmake'
          else:
@@ -467,8 +469,9 @@ macx {
          # TODO: is this still necessary for Python v3.8?
          if not buildable.static:
              pro_lines.extend(['win32 {',
-                    '    LIBS += -L{}'.format(
- self.qmake_quote(project.py_pylib_dir)),
+                    '    LIBS += -L{libdir} -l{lib}'.format(
+ libdir=self.qmake_quote(project.py_pylib_dir),
+ lib=self.qmake_quote(project.py_pylib_lib)),
                      '}'])

          # Add any installables from the buildable.



More information about the PyQt mailing list