OpenMiInk/third_party/krita-deps-management/ext_pyqt-builder/0001-Fix-support-for-MinGW-builds.patch
Hellings b8c8ff98e2 Hi
2026-10-16 09:05:56 -04:00

119 lines
4.4 KiB
Diff

From 78e53a03fcf68cc7c8a641d46901c1daeed21376 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Sat, 29 Mar 2025 11:28:22 +0100
Subject: [PATCH] Fix support for MinGW builds
---
pyqtbuild/builder.py | 26 ++++++++++++++++++++------
pyqtbuild/project.py | 6 +++++-
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/pyqtbuild/builder.py b/pyqtbuild/builder.py
index bc65517..4bedc0e 100644
--- a/pyqtbuild/builder.py
+++ b/pyqtbuild/builder.py
@@ -6,6 +6,11 @@
import os
import sys
+try:
+ from sysconfig import _POSIX_BUILD
+except:
+ _POSIX_BUILD = False
+
from sipbuild import (Buildable, BuildableModule, Builder, Option, Project,
PyProjectOptionException, UserException)
@@ -39,7 +44,7 @@ class QmakeBuilder(Builder):
exe_dir, exe_name = os.path.split(sys.argv[0])
if exe_name.startswith('sip-'):
- self._sip_distinfo = os.path.join(os.path.abspath(exe_dir),
+ self._sip_distinfo = os.path.join(os.path.abspath(exe_dir.replace('\\', '/')),
self._sip_distinfo)
# Check we have a qmake.
@@ -230,8 +235,13 @@ class QmakeBuilder(Builder):
['install_' + installable.name
for installable in project.installables])))
pro_lines.append('distinfo.extra = {}'.format(' '.join(args)))
+ if self.project.py_platform == 'win32' and "MSYSTEM" in os.environ:
+ distinfo_dir = os.popen(
+ ' '.join(['cygpath', '--unix', target_dir])).readline().strip()
+ else:
+ distinfo_dir = target_dir
pro_lines.append(
- 'distinfo.path = {}'.format(self.qmake_quote(target_dir)))
+ 'distinfo.path = {}'.format(self.qmake_quote(distinfo_dir)))
pro_lines.append('INSTALLS += distinfo')
pro_name = os.path.join(project.build_dir, project.name + '.pro')
@@ -329,6 +339,8 @@ class QmakeBuilder(Builder):
if self.project.py_platform == 'win32':
if 'g++' in self.spec:
make = 'make'
+ if self._find_exe(make) is None:
+ make = 'mingw32-make'
else:
make = 'nmake'
else:
@@ -455,11 +467,10 @@ macx {
# Python.h on Windows seems to embed the need for pythonXY.lib, so tell
# it where it is.
- # 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{} -l{}'.format(
+ self.qmake_quote(project.py_pylib_dir), self.qmake_quote(project.py_pylib_lib)),
'}'])
# Add any installables from the buildable.
@@ -490,6 +501,9 @@ macx {
"Unexpected output from qmake: '{0}'".format(line))
name, value = tokens
+ if _POSIX_BUILD and "MSYSTEM" in os.environ and value != "":
+ value = os.popen(
+ ' '.join(['cygpath', '--unix', value])).readline().strip()
else:
name = tokens
value = None
@@ -624,7 +638,7 @@ macx {
if install:
args.append('install')
- elif project.py_platform != 'win32' and self.jobs:
+ elif 'make' in args[0] and self.jobs:
args.append('-j')
args.append(str(self.jobs))
diff --git a/pyqtbuild/project.py b/pyqtbuild/project.py
index ba1e54e..3a79feb 100644
--- a/pyqtbuild/project.py
+++ b/pyqtbuild/project.py
@@ -5,6 +5,10 @@
import os
import sys
+try:
+ from sysconfig import _POSIX_BUILD
+except:
+ _POSIX_BUILD = False
from sipbuild import Option, Project, UserException
@@ -56,7 +60,7 @@ class PyQtProject(Project):
# Get the details of the default Python interpreter library. Note that
# these are actually non-user options but we need the 'link_full_dll'
# user option in order to set them.
- if self.py_platform == 'win32':
+ if self.py_platform == 'win32' and not _POSIX_BUILD:
pylib_dir = os.path.join(sys.base_prefix, 'libs')
debug_suffix = '_d' if self.py_debug else ''
--
2.23.0.windows.1