Skip to content

Commit 16d21cf

Browse files
committed
Add Win32 CI
1 parent cae3702 commit 16d21cf

File tree

6 files changed

+169
-25
lines changed

6 files changed

+169
-25
lines changed

.github/workflows/build.yml

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
echo ============================
5656
qmake -r PythonQt.pro CONFIG+=release CONFIG+=sanitizer CONFIG+=sanitize_undefined \
5757
PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \
58-
PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname)
58+
PYTHON_PATH=$(which python3 | xargs dirname)
5959
make -j 2 && make check TESTARGS="-platform offscreen"
6060
6161
- name: Generate Wrappers
@@ -115,7 +115,7 @@ jobs:
115115
echo ============================
116116
qmake-qt5 -r PythonQt.pro CONFIG+=release \
117117
PYTHON_VERSION=$(python --version | cut -d " " -f 2 | cut -d "." -f1,2) \
118-
PYTHON_DIR=$(which python | xargs dirname | xargs dirname)
118+
PYTHON_PATH=$(which python | xargs dirname)
119119
make -j 2 && make check TESTARGS="-platform offscreen"
120120
121121
- name: Generate Wrappers
@@ -173,7 +173,7 @@ jobs:
173173
set -eu
174174
PYTHON_VERSION_FULL=$(python --version 2>&1 | cut -f 2 -d ' ')
175175
PYTHON_VERSION_SHORT=$(cut -f 1,2 -d . <<< $PYTHON_VERSION_FULL)
176-
QT_VERSION_FULL=$($Qt5_DIR/bin/qmake -query QT_VERSION)
176+
QT_VERSION_FULL=$($Qt5_Dir/bin/qmake -query QT_VERSION)
177177
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< $QT_VERSION_FULL)
178178
MACOS_VERSION_FULL=$(sw_vers -productVersion)
179179
MACOS_VERSION_SHORT=$(cut -f 1,2 -d . <<< $MACOS_VERSION_FULL)
@@ -197,7 +197,7 @@ jobs:
197197
do if pkg-config --exists "$i"; then PYTHON_PKGCONFIG_NAME="$i"; break; fi; done
198198
qmake CONFIG+=release CONFIG+=sanitizer CONFIG+=sanitize_undefined \
199199
PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }} \
200-
PYTHON_DIR="$pythonLocation" \
200+
PYTHON_PATH="$pythonLocation" \
201201
PKGCONFIG+=$PYTHON_PKGCONFIG_NAME \
202202
-r PythonQt.pro
203203
make -j 2 && make check TESTARGS="-platform offscreen"
@@ -206,11 +206,114 @@ jobs:
206206
run: |
207207
cd generator
208208
# workaround to allow to find the Qt include dirs for installed standard qt packages
209-
QTDIR=-UNDEFINED- ./pythonqt_generator --include-paths=$Qt5_DIR/lib
209+
QTDIR=-UNDEFINED- ./pythonqt_generator --include-paths=$Qt5_Dir/lib
210210
211211
- name: Upload Wrappers
212212
uses: actions/upload-artifact@v3
213213
with:
214214
name: wrappers_macos${{ steps.versions.outputs.MACOS_VERSION_SHORT }}_qt${{ steps.versions.outputs.QT_VERSION_SHORT }}
215215
path: generated_cpp
216216

217+
windows:
218+
strategy:
219+
fail-fast: false
220+
matrix:
221+
qt-arch: ['win32_msvc2015']
222+
python-version: ['2.7']
223+
qt-version: ['5.9.*']
224+
python-arch: ['x86']
225+
pythonqtall-config: ['PythonQtCore PythonQtGui PythonQtMultimedia']
226+
# msvc-toolset: ['14.0']
227+
include:
228+
- qt-arch: 'win64_msvc2017_64'
229+
python-version: '3.6'
230+
python-arch: 'x64'
231+
qt-version: '5.11.*'
232+
# msvc-toolset: '14.16'
233+
234+
- qt-arch: 'win32_mingw53'
235+
python-version: '2.7'
236+
python-arch: 'x86'
237+
qt-version: '5.11.*'
238+
239+
- qt-arch: 'win64_mingw73'
240+
python-version: '3.10'
241+
python-arch: 'x64'
242+
qt-version: '5.12.*'
243+
pythonqtall-config: ''
244+
245+
runs-on: windows-latest
246+
steps:
247+
248+
- name: Checkout PythonQt
249+
uses: actions/checkout@v3
250+
251+
- name: Reset PATH
252+
uses: egor-tensin/cleanup-path@v3
253+
254+
- name: Install MSVC++
255+
uses: ilammy/msvc-dev-cmd@v1
256+
if: ${{ contains(matrix.qt-arch, 'msvc') }}
257+
with:
258+
arch: amd64${{ contains(matrix.python-arch, 'x86') && '_x86' || '' }}
259+
# toolset: ${{ matrix.msvc-toolset }}
260+
261+
- name: Install Qt
262+
uses: jurplel/install-qt-action@v3
263+
with:
264+
aqtversion: '==2.1.*'
265+
version: ${{ matrix.qt-version }}
266+
host: 'windows'
267+
target: 'desktop'
268+
arch: ${{ matrix.qt-arch }}
269+
modules: 'qtscript'
270+
archives: 'qtwinextras qtmultimedia qtbase'
271+
tools: ${{ contains(matrix.qt-arch, 'mingw') && format('tools_mingw,qt.tools.{0}0', matrix.qt-arch) || '' }}
272+
273+
- name: Setup Python ${{ matrix.python-version }}
274+
uses: actions/setup-python@v4
275+
with:
276+
python-version: '${{ matrix.python-version }}'
277+
architecture: ${{ matrix.python-arch }}
278+
279+
- name: Detect exact versions
280+
shell: bash
281+
id: versions
282+
run: |
283+
echo PATH=$PATH
284+
set -eu
285+
QT_VERSION_FULL=$($Qt5_Dir/bin/qmake -query QT_VERSION)
286+
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< $QT_VERSION_FULL)
287+
echo "QT_VERSION_FULL=$QT_VERSION_FULL" | tee -a $GITHUB_OUTPUT
288+
echo "QT_VERSION_SHORT=$QT_VERSION_SHORT" | tee -a $GITHUB_OUTPUT
289+
echo "CL=/MP" | tee -a $GITHUB_ENV #multicore parallel build for cl.exe
290+
291+
- name: Add Qt and MinGW to PATH
292+
shell: cmd
293+
run: |
294+
set "ADDPATH=%Qt5_Dir%\bin"
295+
${{ 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') || '' }}
296+
echo PATH=%ADDPATH%;%PATH% >> %GITHUB_ENV%
297+
298+
- name: Build PythonQt
299+
shell: cmd
300+
run: |
301+
qmake -query
302+
qmake -Wall -d CONFIG+=release CONFIG-=debug_and_release CONFIG-=debug_and_release_target "PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }}" "PYTHON_PATH=%pythonLocation%" -after "QMAKE_SH=" "QMAKE_LINK_OBJECT_MAX=100" PythonQt.pro
303+
mingw32-make -j 2 && mingw32-make check "TESTARGS=-platform offscreen" || nmake && nmake check "TESTARGS=-platform offscreen"
304+
305+
- name: Generate Wrappers
306+
shell: cmd
307+
run: |
308+
cd generator
309+
rem Workaround to allow to find the Qt include dirs for installed standard qt packages
310+
set QTDIR=%Qt5_Dir%
311+
set PATH=%Qt5_Dir%\bin;%PATH%
312+
pythonqt_generator
313+
314+
- name: Upload Wrappers
315+
if: false
316+
uses: actions/upload-artifact@v3
317+
with:
318+
name: wrappers_${{ matrix.qt-arch }}_${{ steps.versions.outputs.QT_VERSION_SHORT }}
319+
path: generated_cpp

build/python.prf

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,43 @@
55
isEmpty( PYTHON_VERSION ) {
66
PYTHON_VERSION=$$(PYTHON_VERSION)
77
}
8-
isEmpty( PYTHON_VERSION ) {
9-
win32:PYTHON_VERSION=27
10-
unix:PYTHON_VERSION=2.7
8+
9+
isEmpty(PYTHON_DIR):PYTHON_DIR=$$(PYTHON_DIR)
10+
!isEmpty(PYTHON_DIR):error(Use PYTHON_PATH to choose exact Python installation instead of PYTHON_DIR)
11+
12+
isEmpty( PYTHON_PATH ) {
13+
PYTHON_PATH=$$(PYTHON_PATH)
14+
}
15+
16+
!isEmpty( PYTHON_PATH ) {
17+
PYTHON_PATH=$$system_path($${PYTHON_PATH}$${QMAKE_DIR_SEP})
1118
}
1219

13-
isEmpty( PYTHON_DIR ) {
14-
PYTHON_DIR=$$(PYTHON_DIR)
20+
isEmpty(PYTHON_CMD):PYTHON_CMD=$$(PYTHON_CMD)
21+
isEmpty(PYTHON_CMD):PYTHON_CMD=python
22+
!isEmpty(PYTHON_PATH):PYTHON_CMD=$${PYTHON_PATH}$${QMAKE_DIR_SEP}$${PYTHON_CMD}
23+
contains(QMAKE_HOST.os, Windows):PYTHON_CMD=$${PYTHON_CMD}.exe
24+
PYTHON_CMD=$$system_path($$PYTHON_CMD)
25+
!isEmpty(PYTHON_PATH):!exists($$PYTHON_CMD):error("Incorrect PYTHON_PATH was set, missing $$PYTHON_CMD")
26+
27+
isEmpty(PYTHON_PATH): PYTHON_PATH=$$system($$system_quote($${PYTHON_CMD}) -c \
28+
$$system_quote(import os;import sys;print(os.path.dirname(sys.executable))))$${QMAKE_DIR_SEP}
29+
30+
#Not just "python --version" because Python 2 outputs `--version` to the stderr
31+
#And there is no simple way known for me to generally redirect stderr to stdout
32+
PYTHON_VERSION_DETECTED=$$system($$system_quote($${PYTHON_CMD}) -c $$system_quote(import sysconfig;print(sysconfig.get_python_version())))
33+
34+
35+
isEmpty( PYTHON_VERSION ) {
36+
warning(PYTHON_VERSION should be set explicitly from qmake command-line or via environment.\
37+
$$escape_expand(\\n\\t) F.e.: $$shell_quote(qmake PYTHON_VERSION=3.6 CONFIG+=release) \
38+
or $$shell_quote(set PYTHON_VERSION=2.7))
39+
message(Trying $${PYTHON_CMD} executable to guess the version)
40+
PYTHON_VERSION=$$PYTHON_VERSION_DETECTED
1541
}
16-
!isEmpty( PYTHON_DIR ) {
17-
PYTHON_DIR=$${PYTHON_DIR}/
42+
43+
!equals(PYTHON_VERSION, $$PYTHON_VERSION_DETECTED){
44+
error("Found Python version $$PYTHON_VERSION_DETECTED, but $$PYTHON_VERSION was requested")
1845
}
1946

2047
PYTHON_VERSION_MAJOR=$$section(PYTHON_VERSION, ., 0, 0)
@@ -26,18 +53,22 @@ PYTHON_VERSION_MINOR=$$section(PYTHON_VERSION, ., 1, 1)
2653
message(Using Python version $${PYTHON_VERSION})
2754
}
2855

29-
3056
# Python 2.x has problems:
3157
# 1) https://wiki.gentoo.org/wiki/Project:Python/Strict_aliasing
3258
# 2) deprecated implicit cast of string literals to char*
33-
equals(PYTHON_VERSION_MAJOR, 2):gcc:QMAKE_CXXFLAGS *= -fno-strict-aliasing -Wno-error=write-strings
59+
equals(PYTHON_VERSION_MAJOR, 2) {
60+
gcc:QMAKE_CXXFLAGS *= -fno-strict-aliasing -Wno-error=write-strings
61+
# Qt 5.4 adds this option, but this is not compatible with the Python API
62+
msvc: QMAKE_CXXFLAGS -= -Zc:strictStrings
63+
}
64+
3465
contains(PKGCONFIG, "python.*"){
3566
CONFIG += link_pkgconfig
3667
PYTHON_PKGCONFIG = $$member($$unique($$find(PKGCONFIG, "python.*")), 1, 1)
3768
# add rpath
3869
PYTHON_LIBDIR = $$system($$pkgConfigExecutable() --libs-only-L $$PYTHON_PKGCONFIG)
3970
QMAKE_RPATHDIR += $$replace(PYTHON_LIBDIR,-L,)
40-
} else:macx:isEmpty(PYTHON_DIR){
71+
} else:macx:isEmpty(PYTHON_PATH){
4172
# for macx you need to have the Python development kit installed as framework
4273
INCLUDEPATH += /System/Library/Frameworks/Python.framework/Headers
4374
LIBS += -F/System/Library/Frameworks -framework Python
@@ -63,13 +94,21 @@ contains(PKGCONFIG, "python.*"){
6394
DEBUG_EXT =
6495
}
6596

66-
win32:INCLUDEPATH += $$(PYTHON_PATH)/PC $$(PYTHON_PATH)/include
67-
win32:LIBS += $$(PYTHON_LIB)/python$${PYTHON_VERSION}$${DEBUG_EXT}.lib
97+
INCLUDEPATH += $$system($$system_quote($${PYTHON_CMD}) -c \
98+
$$system_quote(import sysconfig;print(\'\"%s\" \"%s\"\'%(sysconfig.get_paths()[\'include\'],sysconfig.get_paths()[\'platinclude\']))))
99+
100+
101+
LIBS += -L$${PYTHON_PATH}libs
102+
LIBS += -lpython$${PYTHON_VERSION_MAJOR}$${PYTHON_VERSION_MINOR}
103+
104+
# Hack for "CONFIG+=testcase" and 'make check' to add python's dll to PATH
105+
deppath += $$PYTHON_PATH
106+
68107
} else:unix {
69108
# on linux, python-config is used to autodetect Python.
70109
# make sure that you have installed a matching python-dev package.
71110

72-
PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_VERSION}-config
111+
PYTHON_CONFIG = $${PYTHON_PATH}python$${PYTHON_VERSION}-config
73112
PYTHON_CONFIG_OPTIONS_LIBS = --libs
74113
equals(PYTHON_VERSION_MAJOR, 3):!lessThan(PYTHON_VERSION_MINOR, 8) {
75114
# Since 3.8 `--embed` is needed

extensions/PythonQt_QtAll/PythonQt_QtAll.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ defineTest(Xinclude) {
7474
PythonQtCore {
7575
DEFINES += PYTHONQT_WITH_CORE
7676
Xinclude (com_trolltech_qt_core)
77+
QT += core
7778
}
7879

7980
PythonQtGui {
@@ -85,7 +86,7 @@ PythonQtGui {
8586
PythonQtSvg {
8687
DEFINES += PYTHONQT_WITH_SVG
8788
Xinclude (com_trolltech_qt_svg)
88-
QT +=svg
89+
QT += svg
8990
}
9091

9192
PythonQtSql {

src/PythonQt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,6 @@ QString PythonQtPrivate::getSignature(PyObject* object)
24262426
Py_DECREF(s);
24272427
}
24282428
}
2429-
24302429
QStringList arguments;
24312430
QStringList defaults;
24322431
QString varargs;

src/src.pri

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ INCLUDEPATH += $$PWD
55
CONFIG += c++11
66

77
gcc:!no_warn {
8-
!clang:QMAKE_CXXFLAGS += -Werror -Wno-error=missing-field-initializers
8+
!clang:QMAKE_CXXFLAGS += -Wno-error=missing-field-initializers
9+
#equals(QT_MAJOR_VERSION,5):lessThan(QT_MINOR_VERSION,12) {
10+
#for backward compatibility, otherwise newer options cause old GCC to fail
11+
# But -Wno-... is allowed by GCC for backward compatibility
12+
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
13+
#QMAKE_CXXFLAGS += -Wno-deprecated-copy
14+
#}
915
clang:QMAKE_CXXFLAGS += -Wno-error=sometimes-uninitialized
1016
}
1117

src/src.pro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
TARGET = PythonQt-Qt5-PythonXY
88
TEMPLATE = lib
99

10-
1110
DESTDIR = ../lib
1211

1312
CONFIG += qt
@@ -31,9 +30,6 @@ DEFINES += PYTHONQT_CATCH_ALL_EXCEPTIONS
3130
contains(QT_MAJOR_VERSION, 5) {
3231
QT += widgets core-private
3332
}
34-
35-
# Qt 5.4 adds this option, but this is not compatible with the Python API
36-
QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
3733

3834
INCLUDEPATH += $$PWD
3935

0 commit comments

Comments
 (0)