Visitar URL original
Fix build with Python 3.13 (#246) · SimcenterMbse/pythonqt6@d23463c · GitHub
Skip to content

Commit d23463c

Browse files
FabioLolixNathanBensimon
authored andcommitted
Fix build with Python 3.13 (MeVisLab#246)
* Fix build with Python 3.13, fixes MeVisLab#245 * Update build.yml to python 3.13
1 parent ed17bb4 commit d23463c

2 files changed

Lines changed: 108 additions & 72 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 108 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ on:
55
branches:
66
- master
77
pull_request:
8-
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
15+
916
defaults:
1017
run:
1118
shell: bash
@@ -15,11 +22,11 @@ jobs:
1522
strategy:
1623
fail-fast: false
1724
matrix:
18-
container:
19-
- 'ubuntu:20.04'
20-
- 'ubuntu:22.04'
25+
container_version:
26+
- '20.04'
27+
- '22.04'
2128
runs-on: ubuntu-latest
22-
container: ${{ matrix.container }}
29+
container: ubuntu:${{ matrix.container_version }}
2330
steps:
2431
- name: Install Qt
2532
run: |
@@ -45,60 +52,85 @@ jobs:
4552
apt-get clean
4653
4754
- name: Checkout PythonQt
48-
uses: actions/checkout@v3
55+
uses: actions/checkout@v4
4956

57+
- name: Ccache
58+
uses: hendrikmuhs/ccache-action@v1.2.14
59+
with:
60+
key: ${{ runner.os }}-ubuntu-${{ matrix.container_version }}
61+
5062
- name: Build PythonQt
5163
run: |
5264
export QT_SELECT=qt5
5365
echo ======= SYSTEM INFO ========
5466
uname -a; gcc --version | grep "gcc"; python3 --version; qmake --version
5567
echo ============================
56-
qmake -r PythonQt.pro CONFIG+=release CONFIG+=sanitizer CONFIG+=sanitize_undefined \
68+
qmake -r PythonQt.pro CONFIG+=ccache CONFIG+=release CONFIG+=force_debug_info \
69+
CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=sanitize_address \
5770
PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \
5871
PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname)
59-
make -j 2
60-
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
72+
make -j $(nproc)
73+
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
74+
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
6175
make check TESTARGS="-platform offscreen"
76+
77+
- name: Run memory tests with sanitizers
78+
run: |
79+
QT_VERSION_FULL=$(qmake -query QT_VERSION)
80+
if [[ "$QT_VERSION_FULL" == 5.12* ]]; then
81+
echo "leak:QPlatformIntegrationFactory::create" >> $PWD/lsan.supp
82+
export LSAN_OPTIONS="suppressions=$PWD/lsan.supp"
83+
fi
84+
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
85+
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=1:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
86+
PYTHONQT_RUN_ONLY_MEMORY_TESTS=1 \
87+
make check TESTARGS="-platform minimal"
6288
6389
- name: Generate Wrappers
6490
run: |
6591
# workaround to allow to find the Qt include dirs for installed standard qt packages
6692
mkdir /usr/include/qt5; ln -s /usr/include/x86_64-linux-gnu/qt5 /usr/include/qt5/include
6793
export QTDIR=/usr/include/qt5
6894
cd generator
95+
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
6996
./pythonqt_generator
7097
7198
- name: Upload Wrappers
72-
uses: actions/upload-artifact@v3
73-
if: ${{ matrix.container }} == 'ubuntu:20.04'
74-
with:
75-
name: wrappers_ubuntu_20_04
76-
path: generated_cpp
77-
78-
- name: Upload Wrappers
79-
uses: actions/upload-artifact@v3
80-
if: ${{ matrix.container }} == 'ubuntu:22.04'
99+
uses: actions/upload-artifact@v4
81100
with:
82-
name: wrappers_ubuntu_22_04
101+
name: wrappers_ubuntu_${{ matrix.container_version }}
83102
path: generated_cpp
84103

85-
centos:
104+
oldschool:
86105
strategy:
87106
fail-fast: false
88107
matrix:
89-
container:
90-
- 'centos:7'
108+
container_os: ['centos']
109+
container_os_version: ['7']
110+
container_os_python_package: ['python-debug']
91111
configuration: ['debug', 'release']
112+
include:
113+
- container_os: 'rockylinux'
114+
container_os_version: '9'
115+
container_os_python_package: 'python3-devel'
116+
configuration: 'release'
92117
runs-on: ubuntu-latest
93-
container: ${{ matrix.container }}
118+
container: '${{ matrix.container_os }}:${{ matrix.container_os_version }}'
94119
steps:
120+
- name: Change centos archive repository
121+
run: |
122+
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
123+
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
124+
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
125+
if: matrix.container_os == 'centos'
126+
95127
- name: Install Qt
96128
run: |
97129
yum update -y
98130
yum groupinstall "Development Tools" -y
99131
yum install -y \
100132
which \
101-
python-debug \
133+
${{ matrix.container_os_python_package }} \
102134
qt5-qtbase-* \
103135
qt5-qttools* \
104136
qt5-qtsvg \
@@ -114,50 +146,52 @@ jobs:
114146
run: |
115147
export QT_SELECT=qt5
116148
echo ======= SYSTEM INFO ========
117-
uname -a; gcc --version | grep "gcc"; python --version; qmake-qt5 --version
149+
which python 2>/dev/null && export PYTHON_VERSION_SUFFIX= || export PYTHON_VERSION_SUFFIX=3
150+
uname -a; gcc --version | grep "gcc"; python${PYTHON_VERSION_SUFFIX} --version; qmake-qt5 --version
118151
echo ============================
152+
export PYTHON_VERSION_SHORT=`python${PYTHON_VERSION_SUFFIX} --version | cut -d " " -f 2 | cut -d "." -f1,2`
153+
if [[ `echo ${PYTHON_VERSION_SHORT} | wc -w` = 0 ]]; then export PYTHON_VERSION_SHORT=2.7; fi
154+
export PYTHON_DIR=`which python${PYTHON_VERSION_SUFFIX} | xargs dirname | xargs dirname`
155+
echo PYTHON_VERSION_SHORT=${PYTHON_VERSION_SHORT}
156+
echo PYTHON_DIR=${PYTHON_DIR}
119157
qmake-qt5 -r PythonQt.pro CONFIG+=${{ matrix.configuration }} \
120-
PYTHON_VERSION=$(python --version | cut -d " " -f 2 | cut -d "." -f1,2) \
121-
PYTHON_DIR=$(which python | xargs dirname | xargs dirname)
122-
make -j 2 && make check TESTARGS="-platform offscreen"
123-
158+
"PYTHON_VERSION=${PYTHON_VERSION_SHORT}" "PYTHON_DIR=${PYTHON_DIR}"
159+
make -j $(nproc) && \
160+
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
161+
make check TESTARGS="-platform offscreen"
162+
124163
- name: Generate Wrappers
125164
run: |
126165
# workaround to allow to find the Qt include dirs for installed standard qt packages
127166
mkdir /usr/include/qt5ln; ln -s /usr/include/qt5 /usr/include/qt5ln/include
128167
export QTDIR=/usr/include/qt5ln
129168
cd generator
130169
./pythonqt_generator
131-
170+
132171
- name: Upload Wrappers
133172
uses: actions/upload-artifact@v3
134173
with:
135-
name: wrappers_centos7
174+
name: wrappers_${{ matrix.container_os }}-${{ matrix.container_os_version }}_${{ matrix.configuration }}
136175
path: generated_cpp
137176

138177
macOS:
139178
strategy:
140179
fail-fast: false
141180
matrix:
142-
macos-version: ['10.15']
143-
python-version: ['2.7']
181+
macos-version: ['latest']
182+
python-version: ['3.9']
144183
qt-version: ['5.9.*']
145184
configuration: ['release','debug']
146185
include:
147-
- macos-version: '11'
148-
python-version: '3.6'
149-
qt-version: '5.11.*'
150-
configuration: 'release'
151-
- macos-version: '12'
186+
- macos-version: 'latest'
152187
python-version: '3.11'
153188
qt-version: '5.12.*'
154189
configuration: 'debug'
155190
runs-on: macos-${{ matrix.macos-version }}
156191
steps:
157192
- name: Install Qt
158-
uses: jurplel/install-qt-action@v3
193+
uses: jurplel/install-qt-action@v4
159194
with:
160-
aqtversion: '==2.1.*'
161195
version: ${{ matrix.qt-version }}
162196
host: 'mac'
163197
target: 'desktop'
@@ -166,20 +200,25 @@ jobs:
166200
archives: 'qtmultimedia qtmacextras qtbase qttools'
167201

168202
- name: Setup Python ${{ matrix.python-version }}
169-
uses: actions/setup-python@v4
203+
uses: actions/setup-python@v5
170204
with:
171205
python-version: '${{ matrix.python-version }}'
172206

173207
- name: Checkout PythonQt
174-
uses: actions/checkout@v3
208+
uses: actions/checkout@v4
175209

210+
- name: Ccache
211+
uses: hendrikmuhs/ccache-action@v1.2.14
212+
with:
213+
key: ${{ runner.os }}-${{ matrix.qt-version }}
214+
176215
- name: Detect exact versions
177216
id : versions
178217
run : |
179218
set -eu
180219
PYTHON_VERSION_FULL=$(python --version 2>&1 | cut -f 2 -d ' ')
181220
PYTHON_VERSION_SHORT=$(cut -f 1,2 -d . <<< $PYTHON_VERSION_FULL)
182-
QT_VERSION_FULL=$($Qt5_Dir/bin/qmake -query QT_VERSION)
221+
QT_VERSION_FULL=$($QT_ROOT_DIR/bin/qmake -query QT_VERSION)
183222
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< $QT_VERSION_FULL)
184223
MACOS_VERSION_FULL=$(sw_vers -productVersion)
185224
MACOS_VERSION_SHORT=$(cut -f 1,2 -d . <<< $MACOS_VERSION_FULL)
@@ -201,24 +240,26 @@ jobs:
201240
for i in "python${{ steps.versions.outputs.PYTHON_VERSION_SHORT }}-embed" "python${{ steps.versions.outputs.PYTHON_VERSION_SHORT }}" \
202241
"python${PYTHON_VERSION_MAJOR}-embed" "python${PYTHON_VERSION_MAJOR}"
203242
do if pkg-config --exists "$i"; then PYTHON_PKGCONFIG_NAME="$i"; break; fi; done
204-
qmake CONFIG+=${{ matrix.configuration }} CONFIG+=sanitizer CONFIG+=sanitize_undefined \
243+
qmake CONFIG+=ccache CONFIG+=${{ matrix.configuration }} CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=sanitize_address \
205244
PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }} \
206245
PYTHON_DIR="$pythonLocation" \
207246
PKGCONFIG+=$PYTHON_PKGCONFIG_NAME \
208247
-r PythonQt.pro
209-
make -j 2
210-
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
248+
make -j $(nproc)
249+
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
250+
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
211251
make check TESTARGS="-platform offscreen"
212252
213253
- name: Generate Wrappers
214254
if: ${{ contains(matrix.configuration, 'release') }}
215255
run: |
216256
cd generator
217257
# workaround to allow to find the Qt include dirs for installed standard qt packages
218-
QTDIR=-UNDEFINED- ./pythonqt_generator --include-paths=$Qt5_Dir/lib
258+
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
259+
QTDIR=-UNDEFINED- ./pythonqt_generator --qt-version=${{ steps.versions.outputs.QT_VERSION_FULL }} --include-paths=$QT_ROOT_DIR/lib
219260
220261
- name: Upload Wrappers
221-
uses: actions/upload-artifact@v3
262+
uses: actions/upload-artifact@v4
222263
with:
223264
name: wrappers_macos${{ steps.versions.outputs.MACOS_VERSION_SHORT }}_qt${{ steps.versions.outputs.QT_VERSION_SHORT }}
224265
path: generated_cpp
@@ -240,8 +281,14 @@ jobs:
240281
qt-version: '5.11.*'
241282
# msvc-toolset: '14.16'
242283

284+
- qt-arch: 'win64_msvc2019_64'
285+
python-version: '3.13'
286+
python-arch: 'x64'
287+
qt-version: '5.15.*'
288+
pythonqtall-config: 'PythonQtCore PythonQtGui PythonQtMultimedia'
289+
243290
- qt-arch: 'win32_mingw53'
244-
python-version: '2.7'
291+
python-version: '3.6'
245292
python-arch: 'x86'
246293
qt-version: '5.11.*'
247294

@@ -257,10 +304,10 @@ jobs:
257304
steps:
258305

259306
- name: Checkout PythonQt
260-
uses: actions/checkout@v3
307+
uses: actions/checkout@v4
261308

262309
- name: Reset PATH
263-
uses: egor-tensin/cleanup-path@v3
310+
uses: egor-tensin/cleanup-path@v4
264311

265312
- name: Install MSVC++
266313
uses: ilammy/msvc-dev-cmd@v1
@@ -269,9 +316,8 @@ jobs:
269316
arch: amd64${{ contains(matrix.python-arch, 'x86') && '_x86' || '' }}
270317

271318
- name: Install Qt
272-
uses: jurplel/install-qt-action@v3
319+
uses: jurplel/install-qt-action@v4
273320
with:
274-
aqtversion: '==2.1.*'
275321
version: ${{ matrix.qt-version }}
276322
host: 'windows'
277323
target: 'desktop'
@@ -291,44 +337,40 @@ jobs:
291337
id: versions
292338
run: |
293339
set -eu
294-
QT_VERSION_FULL=$("$Qt5_Dir/bin/qmake" -query QT_VERSION)
340+
QT_VERSION_FULL=$("$QT_ROOT_DIR/bin/qmake" -query QT_VERSION)
295341
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< $QT_VERSION_FULL)
296342
PYTHON_VERSION_FULL=$(python --version 2>&1 | cut -f 2 -d ' ')
297343
PYTHON_VERSION_SHORT=$(cut -f 1,2 -d . <<< $PYTHON_VERSION_FULL)
298344
echo "QT_VERSION_FULL=$QT_VERSION_FULL" | tee -a $GITHUB_OUTPUT
299345
echo "QT_VERSION_SHORT=$QT_VERSION_SHORT" | tee -a $GITHUB_OUTPUT
300346
echo "PYTHON_VERSION_SHORT=$PYTHON_VERSION_SHORT" | tee -a $GITHUB_OUTPUT
301347
302-
- name: Add Qt and MinGW to PATH
303-
shell: cmd
304-
run: |
305-
set "ADDPATH=%Qt5_Dir%\bin"
306-
${{ contains(matrix.qt-arch, 'mingw') && format('FOR /F "tokens=1,2 delims=_" %%I IN ("{0}") DO SET "ADDPATH=%ADDPATH%;%IQTA_TOOLS%\%%J0_{1}\bin', matrix.qt-arch, contains(matrix.qt-arch, 'win32') && '32' || '64') || '' }}
307-
echo PATH=%ADDPATH%;%PATH% >> %GITHUB_ENV%
308-
echo CL=/MP >> $GITHUB_ENV
309-
310348
- name: Build PythonQt
311349
shell: cmd
312350
run: |
313351
qmake -query
314352
python --version
353+
set PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }}
315354
qmake CONFIG+=release CONFIG-=debug_and_release CONFIG-=debug_and_release_target ^
316-
"PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }}" ^
317355
"PYTHON_PATH=%pythonLocation%" ^
318356
"PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }}" ^
319357
PythonQt.pro
358+
set PYTHONDEVMODE=1
359+
set PYTHONASYNCIODEBUG=1
360+
set PYTHONWARNINGS=error
320361
mingw32-make -j 2 && mingw32-make check "TESTARGS=-platform offscreen" ^
321-
|| nmake && nmake check "TESTARGS=-platform offscreen"
362+
|| set CL=/MP && nmake && nmake check "TESTARGS=-platform offscreen"
322363
323364
- name: Generate Wrappers
324365
shell: cmd
325366
run: |
326367
cd generator
327-
set QTDIR=%Qt5_Dir%
368+
set QTDIR=%QT_ROOT_DIR%
328369
pythonqt_generator
329370
330371
- name: Upload Wrappers
331-
uses: actions/upload-artifact@v3
372+
if: (matrix.pythonqtall-config || '') == ''
373+
uses: actions/upload-artifact@v4
332374
with:
333375
name: wrappers_${{ matrix.qt-arch }}_${{ steps.versions.outputs.QT_VERSION_SHORT }}
334376
path: generated_cpp

‎src/PythonQt.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,6 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName)
377377
Py_Initialize();
378378
}
379379

380-
#ifdef PYTHONQT_FULL_THREAD_SUPPORT
381-
if (!PyEval_ThreadsInitialized()) {
382-
PyEval_InitThreads();
383-
}
384-
#endif
385-
386380
// add our own python object types for qt object slots
387381
if (PyType_Ready(&PythonQtSlotFunction_Type) < 0) {
388382
std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;

0 commit comments

Comments
 (0)