From 61fed4ffbf9989bfec084d038d7012a57731601e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Mon, 27 Nov 2023 07:18:40 +0100 Subject: [PATCH] python-pivy: build against soqt-qt6 on non-i686 environments --- mingw-w64-python-pivy/003-find-qt6.patch | 42 ++++++++++++ .../004-fix-compile-flags.patch | 28 ++++++++ .../005-fix-install-destination.patch | 12 ++++ mingw-w64-python-pivy/PKGBUILD | 65 ++++++++++++++----- 4 files changed, 130 insertions(+), 17 deletions(-) create mode 100644 mingw-w64-python-pivy/003-find-qt6.patch create mode 100644 mingw-w64-python-pivy/004-fix-compile-flags.patch create mode 100644 mingw-w64-python-pivy/005-fix-install-destination.patch diff --git a/mingw-w64-python-pivy/003-find-qt6.patch b/mingw-w64-python-pivy/003-find-qt6.patch new file mode 100644 index 0000000000..8814c70d11 --- /dev/null +++ b/mingw-w64-python-pivy/003-find-qt6.patch @@ -0,0 +1,42 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -11,7 +11,7 @@ + find_package(SoQt CONFIG) + + if (SoQt_FOUND) +- find_package(Qt5 COMPONENTS Core Widgets Gui REQUIRED) ++ find_package(Qt6 COMPONENTS Core Widgets Gui REQUIRED) + endif() + + find_package(Python REQUIRED COMPONENTS Interpreter Development) +--- a/distutils_cmake/CMakeLists.txt ++++ b/distutils_cmake/CMakeLists.txt +@@ -1,5 +1,5 @@ + cmake_minimum_required(VERSION 3.5) +-project(pivy_cmake_setup NONE) ++project(pivy_cmake_setup CXX) + + + find_package(Coin CONFIG REQUIRED) +--- a/qtinfo.py ++++ b/qtinfo.py +@@ -7,7 +7,7 @@ + if qmake_command: + self._qmake_command = qmake_command + else: +- self._qmake_command = [find_executable("qmake"),] ++ self._qmake_command = [find_executable("qmake6"),] + self._dict = {} + # bind all variables early at __init__ time. + for thing in self.__class__.__dict__: +--- a/setup.py ++++ b/setup.py +@@ -573,7 +573,7 @@ + else: + if "MSYSTEM" in os.environ: + CPP_FLAGS += ' -DSOQT_DLL' +- LDFLAGS_LIBS += ' -lSoQt' ++ LDFLAGS_LIBS += ' -lSoQt -lQt6Core' + + if module == "coin": + if sys.platform == 'win32' and "MSYSTEM" not in os.environ: diff --git a/mingw-w64-python-pivy/004-fix-compile-flags.patch b/mingw-w64-python-pivy/004-fix-compile-flags.patch new file mode 100644 index 0000000000..a3f40f985f --- /dev/null +++ b/mingw-w64-python-pivy/004-fix-compile-flags.patch @@ -0,0 +1,28 @@ +--- a/interfaces/CMakeLists.txt ++++ b/interfaces/CMakeLists.txt +@@ -27,7 +27,11 @@ + if (APPLE) + set_target_properties(coin PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + elseif (WIN32) +- set_target_properties(coin PROPERTIES COMPILE_FLAGS "/bigobj") ++ if(MSVC) ++ set_target_properties(coin PROPERTIES COMPILE_FLAGS "/bigobj") ++ elseif(MINGW) ++ set_target_properties(coin PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj") ++ endif() + target_link_libraries(coin PUBLIC ${Python_LIBRARIES}) + endif () + +@@ -62,7 +66,11 @@ + if (APPLE) + set_target_properties(soqt PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + elseif (WIN32) +- set_target_properties(coin PROPERTIES COMPILE_FLAGS "/bigobj") ++ if(MSVC) ++ set_target_properties(coin PROPERTIES COMPILE_FLAGS "/bigobj") ++ elseif(MINGW) ++ set_target_properties(coin PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj") ++ endif() + target_link_libraries(soqt PUBLIC ${Python_LIBRARIES}) + endif () + diff --git a/mingw-w64-python-pivy/005-fix-install-destination.patch b/mingw-w64-python-pivy/005-fix-install-destination.patch new file mode 100644 index 0000000000..d8bdd1eac5 --- /dev/null +++ b/mingw-w64-python-pivy/005-fix-install-destination.patch @@ -0,0 +1,12 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -15,6 +15,9 @@ + endif() + + find_package(Python REQUIRED COMPONENTS Interpreter Development) ++get_filename_component( PYTHON_DIR ${Python_EXECUTABLE} DIRECTORY ) ++get_filename_component( PYTHON_PREFIX "${PYTHON_DIR}/.." REALPATH ) ++string( REPLACE "${PYTHON_PREFIX}/" "" Python_SITEARCH ${Python_SITEARCH} ) + + # SWIGIFY HEADERS + # doing this with the origin python functions diff --git a/mingw-w64-python-pivy/PKGBUILD b/mingw-w64-python-pivy/PKGBUILD index 7442570f7b..7d34e6544f 100644 --- a/mingw-w64-python-pivy/PKGBUILD +++ b/mingw-w64-python-pivy/PKGBUILD @@ -9,33 +9,61 @@ pkgdesc='Python bindings to Coin3D (mingw-w64)' arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32') url='https://github.com/coin3d/pivy' -license=('BSD') +msys2_references=( + 'archlinux: python-pivy' +) +license=('spdx:ISC') depends=("${MINGW_PACKAGE_PREFIX}-python" - "${MINGW_PACKAGE_PREFIX}-soqt-qt5") -makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" + $([[ ${CARCH} != i686 ]] && echo \ + "${MINGW_PACKAGE_PREFIX}-soqt-qt6" || echo \ + "${MINGW_PACKAGE_PREFIX}-soqt-qt5")) +makedepends=("${MINGW_PACKAGE_PREFIX}-python-build" + "${MINGW_PACKAGE_PREFIX}-python-installer" + "${MINGW_PACKAGE_PREFIX}-python-setuptools" + "${MINGW_PACKAGE_PREFIX}-python-wheel" "${MINGW_PACKAGE_PREFIX}-swig" "${MINGW_PACKAGE_PREFIX}-cc" - #"${MINGW_PACKAGE_PREFIX}-glu" - "${MINGW_PACKAGE_PREFIX}-cmake") + "${MINGW_PACKAGE_PREFIX}-cmake" + "${MINGW_PACKAGE_PREFIX}-ninja") source=("${_realname}-${pkgver}.tar.gz"::"${url}/archive/${pkgver}.tar.gz" "001-pivy-0.6.5-setup-py-msystem-env.patch" - "002-pivy-0.6.8-fake-header-cmath.patch") + "002-pivy-0.6.8-fake-header-cmath.patch" + "003-find-qt6.patch" + "004-fix-compile-flags.patch" + "005-fix-install-destination.patch") sha256sums=('c443dd7dd724b0bfa06427478b9d24d31e0c3b5138ac5741a2917a443b28f346' '0a37cf9f25ed3b0aca4547b484f448c840cf6a4d1f604ceed7094f8970a9c5b5' - 'b0132c7cf459c15ab8d35dda1e418140932968b351b325fcccb22e8c05362147') + 'b0132c7cf459c15ab8d35dda1e418140932968b351b325fcccb22e8c05362147' + '653d16af80433e4541e7a5814247b9eccafa2156ce5e10b1fe0fc8c4b4e64a18' + 'e48a9c48999fa6fe01a913357407f13242727cfc350b963b14818c7ed0b348a6' + 'eb9fc0057ace20864aba5faaa68a2feaffef1a6abb948fc21958040cb9824e92') + +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying $_patch" + patch -Nbp1 -i "${srcdir}/$_patch" + done +} prepare() { - cd "${srcdir}" - rm -rf "python-build-${MSYSTEM}" | true - cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}" + cd "${srcdir}"/"${_realname}-${pkgver}" - patch -p1 -i "${srcdir}/001-pivy-0.6.5-setup-py-msystem-env.patch" - patch -p1 -i "${srcdir}/002-pivy-0.6.8-fake-header-cmath.patch" + apply_patch_with_msg \ + 001-pivy-0.6.5-setup-py-msystem-env.patch \ + 002-pivy-0.6.8-fake-header-cmath.patch \ + 004-fix-compile-flags.patch \ + 005-fix-install-destination.patch + + if [[ ${CARCH} != i686 ]]; then + apply_patch_with_msg \ + 003-find-qt6.patch + fi } build() { - msg "Python build for ${MSYSTEM}" - cd "${srcdir}/python-build-${MSYSTEM}" + rm -rf "python-build-${MSYSTEM}" | true + cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}" if [[ "${MSYSTEM}" == "MINGW32" ]]; then # Works around gcc OOM on 32bit somehow @@ -43,13 +71,16 @@ build() { fi GENERATOR="Ninja" \ - ${MINGW_PREFIX}/bin/python setup.py build + ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation } package() { cd "${srcdir}/python-build-${MSYSTEM}" - MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ - ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1 --skip-build + + MSYS2_ARG_CONV_EXCL="--prefix=" \ + ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \ + --destdir="${pkgdir}" dist/*.whl + install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE" }