From 62d6487d59b6c57c82cbaa2688ed41150d9933c1 Mon Sep 17 00:00:00 2001 From: Iakov 'Jake' Kirilenko Date: Mon, 5 Feb 2024 12:00:18 +0300 Subject: [PATCH 1/7] Force C++11 for older Qt versions, safe/useless for 5.7+ --- src/src.pri | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/src.pri b/src/src.pri index 13fe1f62c..68f5bfb23 100644 --- a/src/src.pri +++ b/src/src.pri @@ -2,6 +2,8 @@ DEFINES += PYTHONQT_EXPORTS INCLUDEPATH += $$PWD +CONFIG += c++11 + gcc:!no_warn:!clang:QMAKE_CXXFLAGS += -Wno-error=missing-field-initializers *-clang*:!no_warn:QMAKE_CXXFLAGS += -Wno-error=sometimes-uninitialized From cd59363da3a125d82ca231bc770711f9041f00b8 Mon Sep 17 00:00:00 2001 From: Iakov 'Jake' Kirilenko Date: Mon, 5 Feb 2024 12:01:27 +0300 Subject: [PATCH 2/7] Better reference management pattern --- src/PythonQt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index daea8a184..b1230087f 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -2137,8 +2137,9 @@ PyObject* PythonQtPrivate::packageByName(const char* name) v = PyImport_AddModule((_pythonQtModuleName + "." + name).constData()); _packages.insert(name, v); // AddObject steals the reference, so increment it! - Py_INCREF(v); - PyModule_AddObject(_pythonQtModule, name, v); + if (PyModule_AddObject(_pythonQtModule, name, v) == 0) { + Py_INCREF(v); + } } return v; } From 2cac0f28401cbe808875a400a4b69778f53383d1 Mon Sep 17 00:00:00 2001 From: Iakov 'Jake' Kirilenko Date: Tue, 6 Feb 2024 12:23:47 +0300 Subject: [PATCH 3/7] Add PYTHONDEVMODE to improve tests and other nice options like PYTHONMALLOC=debug_malloc (useful for ASan) and more rigorous warnings handling --- .github/workflows/build.yml | 9 ++++++++- .github/workflows/build_latest.yml | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63fbb35ee..07b47e35b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,6 +58,7 @@ jobs: PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \ PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname) make -j $(nproc) + PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \ UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \ make check TESTARGS="-platform offscreen" @@ -124,7 +125,9 @@ jobs: echo PYTHON_DIR=${PYTHON_DIR} qmake-qt5 -r PythonQt.pro CONFIG+=${{ matrix.configuration }} \ "PYTHON_VERSION=${PYTHON_VERSION_SHORT}" "PYTHON_DIR=${PYTHON_DIR}" - make -j $(nproc) && make check TESTARGS="-platform offscreen" + make -j $(nproc) && \ + PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \ + make check TESTARGS="-platform offscreen" - name: Generate Wrappers run: | @@ -208,6 +211,7 @@ jobs: PKGCONFIG+=$PYTHON_PKGCONFIG_NAME \ -r PythonQt.pro make -j $(nproc) + PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \ UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \ make check TESTARGS="-platform offscreen" @@ -319,6 +323,9 @@ jobs: "PYTHON_PATH=%pythonLocation%" ^ "PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }}" ^ PythonQt.pro + set PYTHONDEVMODE=1 + set PYTHONASYNCIODEBUG=1 + set PYTHONWARNINGS=error mingw32-make -j 2 && mingw32-make check "TESTARGS=-platform offscreen" ^ || nmake && nmake check "TESTARGS=-platform offscreen" diff --git a/.github/workflows/build_latest.yml b/.github/workflows/build_latest.yml index f65fc1074..8b5ed3e28 100644 --- a/.github/workflows/build_latest.yml +++ b/.github/workflows/build_latest.yml @@ -101,6 +101,7 @@ jobs: PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \ PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname) make -j $(nproc) + PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \ UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \ make check TESTARGS="-platform offscreen" @@ -115,5 +116,8 @@ jobs: "PYTHON_PATH=%pythonLocation%" ^ "PYTHON_VERSION=${{ steps.setenv.outputs.PYTHON_VERSION_SHORT }}" ^ PythonQt.pro + set PYTHONDEVMODE=1 + set PYTHONASYNCIODEBUG=1 + set PYTHONWARNINGS=error nmake && nmake check "TESTARGS=-platform offscreen" From 3f7bef9c9a320afd0282488bc6e49ceb2567f04f Mon Sep 17 00:00:00 2001 From: iakov Date: Wed, 8 May 2024 11:42:48 +0300 Subject: [PATCH 4/7] Parse PYTHONQTALL_CONFIG value --- extensions/PythonQt_QtAll/PythonQt_QtAll.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro index 666007c17..8881d00c1 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro +++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro @@ -27,7 +27,7 @@ isEmpty( PYTHONQTALL_CONFIG ) { } else { message("using given PythonQt_QtAll Configuration: ") message(" $${PYTHONQTALL_CONFIG}") - CONFIG += $${PYTHONQTALL_CONFIG} + eval(CONFIG += $${PYTHONQTALL_CONFIG}) } TARGET = PythonQt_QtAll-Qt$${QT_MAJOR_VERSION}-PythonXY From 895a669e37c14fd58645e4c66dc9c4d064446c80 Mon Sep 17 00:00:00 2001 From: iakov Date: Wed, 8 May 2024 11:51:32 +0300 Subject: [PATCH 5/7] Add test for env var PYTHONQTALL_CONFIG --- .github/workflows/build.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07b47e35b..743f1cbd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -246,6 +246,17 @@ jobs: qt-version: '5.11.*' # msvc-toolset: '14.16' + - qt-arch: 'win64_msvc2017_64' + python-version: '3.12' + python-arch: 'x64' + qt-version: '5.15.*' + pythonqtall-config: 'PythonQtCore PythonQtGui PythonQtMultimedia' + + - qt-arch: 'win64_msvc2017_64' + python-version: '3.6' + python-arch: 'x64' + qt-version: '5.11.*' + - qt-arch: 'win32_mingw53' python-version: '3.6' python-arch: 'x86' @@ -318,8 +329,8 @@ jobs: run: | qmake -query python --version + set PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }} qmake CONFIG+=release CONFIG-=debug_and_release CONFIG-=debug_and_release_target ^ - "PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }}" ^ "PYTHON_PATH=%pythonLocation%" ^ "PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }}" ^ PythonQt.pro From 50490720f497726995af20ba101657bfe0a0360c Mon Sep 17 00:00:00 2001 From: iakov Date: Wed, 8 May 2024 12:18:37 +0300 Subject: [PATCH 6/7] MSVC2019 for Qt5.15 test --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 743f1cbd9..63e666ee9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -246,7 +246,7 @@ jobs: qt-version: '5.11.*' # msvc-toolset: '14.16' - - qt-arch: 'win64_msvc2017_64' + - qt-arch: 'win64_msvc2019_64' python-version: '3.12' python-arch: 'x64' qt-version: '5.15.*' From ada272c95bda767f37ec78437adbd93618cdfe4c Mon Sep 17 00:00:00 2001 From: iakov Date: Wed, 8 May 2024 13:29:11 +0300 Subject: [PATCH 7/7] Do not upload artifacts for custom configurations --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63e666ee9..67db5c462 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -348,6 +348,7 @@ jobs: pythonqt_generator - name: Upload Wrappers + if: (matrix.pythonqtall-config || '') == '' uses: actions/upload-artifact@v4 with: name: wrappers_${{ matrix.qt-arch }}_${{ steps.versions.outputs.QT_VERSION_SHORT }}