Skip to content

Me/win32 ci #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 109 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ jobs:
uname -a; gcc --version | grep "gcc"; python3 --version; qmake --version
echo ============================
qmake -r PythonQt.pro CONFIG+=release CONFIG+=sanitizer CONFIG+=sanitize_undefined \
PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \
PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname)
PYTHON_CMD=$(which python3)
make -j 2 && make check TESTARGS="-platform offscreen"

- name: Generate Wrappers
Expand Down Expand Up @@ -114,8 +113,7 @@ jobs:
uname -a; gcc --version | grep "gcc"; python --version; qmake-qt5 --version
echo ============================
qmake-qt5 -r PythonQt.pro CONFIG+=release \
PYTHON_VERSION=$(python --version | cut -d " " -f 2 | cut -d "." -f1,2) \
PYTHON_DIR=$(which python | xargs dirname | xargs dirname)
PYTHON_CMD=$(which python)
make -j 2 && make check TESTARGS="-platform offscreen"

- name: Generate Wrappers
Expand Down Expand Up @@ -173,7 +171,7 @@ jobs:
set -eu
PYTHON_VERSION_FULL=$(python --version 2>&1 | cut -f 2 -d ' ')
PYTHON_VERSION_SHORT=$(cut -f 1,2 -d . <<< $PYTHON_VERSION_FULL)
QT_VERSION_FULL=$($Qt5_DIR/bin/qmake -query QT_VERSION)
QT_VERSION_FULL=$($Qt5_Dir/bin/qmake -query QT_VERSION)
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< $QT_VERSION_FULL)
MACOS_VERSION_FULL=$(sw_vers -productVersion)
MACOS_VERSION_SHORT=$(cut -f 1,2 -d . <<< $MACOS_VERSION_FULL)
Expand All @@ -197,7 +195,7 @@ jobs:
do if pkg-config --exists "$i"; then PYTHON_PKGCONFIG_NAME="$i"; break; fi; done
qmake CONFIG+=release CONFIG+=sanitizer CONFIG+=sanitize_undefined \
PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }} \
PYTHON_DIR="$pythonLocation" \
PYTHON_PATH="$pythonLocation" \
PKGCONFIG+=$PYTHON_PKGCONFIG_NAME \
-r PythonQt.pro
make -j 2 && make check TESTARGS="-platform offscreen"
Expand All @@ -206,11 +204,115 @@ jobs:
run: |
cd generator
# workaround to allow to find the Qt include dirs for installed standard qt packages
QTDIR=-UNDEFINED- ./pythonqt_generator --include-paths=$Qt5_DIR/lib
QTDIR=-UNDEFINED- ./pythonqt_generator --include-paths=$Qt5_Dir/lib

- name: Upload Wrappers
uses: actions/upload-artifact@v3
with:
name: wrappers_macos${{ steps.versions.outputs.MACOS_VERSION_SHORT }}_qt${{ steps.versions.outputs.QT_VERSION_SHORT }}
path: generated_cpp

windows:
strategy:
fail-fast: false
matrix:
qt-arch: ['win64_mingw73']
python-version: ['3.10']
qt-version: ['5.12.*']
python-arch: ['x64']
pythonqtall-config: ['']
# msvc-toolset: ['14.0']
include:
- qt-arch: 'win64_msvc2017_64'
python-version: '3.6'
python-arch: 'x64'
qt-version: '5.11.*'
# msvc-toolset: '14.16'

- qt-arch: 'win32_mingw53'
python-version: '2.7'
python-arch: 'x86'
qt-version: '5.11.*'

#Qt5.9 is sick :(
#Main problem is QBasicMutex with default ctor, that (by no means) is missing in dll-export of QtCore, but linker tries to find it
# - qt-arch: 'win32_msvc2015'
# python-version: '2.7'
# python-arch: 'x86'
# qt-version: '5.9.*'
# pythonqtall-config: 'PythonQtCore PythonQtGui PythonQtMultimedia'

runs-on: windows-latest
steps:

- name: Checkout PythonQt
uses: actions/checkout@v3

- name: Reset PATH
uses: egor-tensin/cleanup-path@v3

- name: Install MSVC++
uses: ilammy/msvc-dev-cmd@v1
if: ${{ contains(matrix.qt-arch, 'msvc') }}
with:
arch: amd64${{ contains(matrix.python-arch, 'x86') && '_x86' || '' }}
# toolset: ${{ matrix.msvc-toolset }}

- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==2.1.*'
version: ${{ matrix.qt-version }}
host: 'windows'
target: 'desktop'
arch: ${{ matrix.qt-arch }}
modules: 'qtscript'
archives: 'qtwinextras qtmultimedia qtbase'
tools: ${{ contains(matrix.qt-arch, 'mingw') && format('tools_mingw,qt.tools.{0}0', matrix.qt-arch) || '' }}

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '${{ matrix.python-version }}'
architecture: ${{ matrix.python-arch }}

- name: Detect exact versions
shell: bash
id: versions
run: |
echo PATH=$PATH
set -eu
QT_VERSION_FULL=$($Qt5_Dir/bin/qmake -query QT_VERSION)
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< $QT_VERSION_FULL)
echo "QT_VERSION_FULL=$QT_VERSION_FULL" | tee -a $GITHUB_OUTPUT
echo "QT_VERSION_SHORT=$QT_VERSION_SHORT" | tee -a $GITHUB_OUTPUT
echo "CL=/MP" | tee -a $GITHUB_ENV #multicore parallel build for cl.exe

- name: Add Qt and MinGW to PATH
shell: cmd
run: |
set "ADDPATH=%Qt5_Dir%\bin"
${{ 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') || '' }}
echo PATH=%ADDPATH%;%PATH% >> %GITHUB_ENV%

- name: Build PythonQt
shell: cmd
run: |
qmake -query
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
mingw32-make -j 2 && mingw32-make check "TESTARGS=-platform offscreen" || nmake && nmake check "TESTARGS=-platform offscreen"

- name: Generate Wrappers
shell: cmd
run: |
cd generator
rem Workaround to allow to find the Qt include dirs for installed standard qt packages
set QTDIR=%Qt5_Dir%
set PATH=%Qt5_Dir%\bin;%PATH%
pythonqt_generator

- name: Upload Wrappers
uses: actions/upload-artifact@v3
with:
name: wrappers_${{ matrix.qt-arch }}_${{ steps.versions.outputs.QT_VERSION_SHORT }}
path: generated_cpp
2 changes: 1 addition & 1 deletion build/PythonQt.prf
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ CONFIG(debug, debug|release) {
}

win32-g++: LIBS += $$DESTDIR/../lib/PythonQt-Qt5-Python$${PYTHON_VERSION}$${DEBUG_EXT}.dll
win32-msvc*: LIBS += $$DESTDIR/../lib/PythonQt-Qt5-Python$${PYTHON_VERSION}$${DEBUG_EXT}.lib
win32-*msvc*: LIBS += $$DESTDIR/../lib/PythonQt-Qt5-Python$${PYTHON_VERSION}$${DEBUG_EXT}.lib
unix: LIBS += -L$$DESTDIR/../lib -lPythonQt-Qt5-Python$${PYTHON_VERSION}$${DEBUG_EXT}
10 changes: 6 additions & 4 deletions build/common.prf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
}
else:contains( QT_MINOR_VERSION, 9 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_59
}
else {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
Expand All @@ -70,7 +70,9 @@ PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp
}

VERSION = 3.2.0

greaterThan(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 9): CONFIG += c++11
win32: CONFIG += skip_target_version_ext
unix: CONFIG += c++11
gcc: QMAKE_CXXFLAGS += -Wno-deprecated-declarations
gcc|clang_cl:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -Wuninitialized -Winit-self -ansi -pedantic
win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-unused-command-line-argument
#Do not issue warning to system includes
gcc:!isEmpty(QT_INSTALL_HEADERS): QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS]
95 changes: 66 additions & 29 deletions build/python.prf
Original file line number Diff line number Diff line change
@@ -1,20 +1,57 @@
# profile to include and link Python


# Change this variable to your python version (2.6, 2.7, 3.3, ...)
isEmpty( PYTHON_VERSION ) {
PYTHON_VERSION=$$(PYTHON_VERSION)
}
isEmpty( PYTHON_VERSION ) {
win32:PYTHON_VERSION=27
unix:PYTHON_VERSION=2.7

isEmpty(PYTHON_DIR):PYTHON_DIR=$$(PYTHON_DIR)
!isEmpty(PYTHON_DIR):error(Use PYTHON_CMD to choose the exact Python installation instead of PYTHON_DIR)

isEmpty(PYTHON_CMD):PYTHON_CMD=$$(PYTHON_CMD)


isEmpty(PYTHON_CMD){
!isEmpty(PYTHON_VERSION) {
PYTHONS_TO_CHECK = python$$PYTHON_VERSION python$$section(PYTHON_VERSION, ., 0, 0)
}
PYTHONS_TO_CHECK += python3 python python2 "Use PYTHON_CMD or PYTHON_VERSION"
PYTHONS_TO_CHECK = $$unique(PYTHONS_TO_CHECK)
for(PYTHON_CMD_ATTEMPT, PYTHONS_TO_CHECK) {
system($$PYTHON_CMD_ATTEMPT --version 1>$$QMAKE_SYSTEM_NULL_DEVICE 2>$$QMAKE_SYSTEM_NULL_DEVICE) {
message("PYTHON_CMD not set, using available $$system_quote(\'$$PYTHON_CMD_ATTEMPT\') command")
PYTHON_CMD=$$PYTHON_CMD_ATTEMPT
break()
}
}
}

isEmpty( PYTHON_DIR ) {
PYTHON_DIR=$$(PYTHON_DIR)
PYTHON_CMD_FULL=$$system_path($$system($$system_quote($$PYTHON_CMD) -c $$system_quote(import sys;print(sys.executable))))

!isEmpty(PYTHON_CMD_FULL):exists($$PYTHON_CMD_FULL) {
PYTHON_CMD="$$PYTHON_CMD_FULL"
} else {
error("Failed to run python: $$system_quote(\"$$PYTHON_CMD\"), try it yourself, please, from command line.")
}
!isEmpty( PYTHON_DIR ) {
PYTHON_DIR=$${PYTHON_DIR}/

PYTHON_PATH=$$system($$system_quote($${PYTHON_CMD}) -c \
$$system_quote(import os;import sys;print(os.path.dirname(sys.executable))))$${QMAKE_DIR_SEP}

#Not just "python --version" because Python 2 outputs `--version` to the stderr
#And there is no simple way known for me to generally redirect stderr to stdout
PYTHON_VERSION_DETECTED=$$system($$system_quote($${PYTHON_CMD}) -c \
$$system_quote(import sysconfig;print(sysconfig.get_python_version())))

isEmpty( PYTHON_VERSION ) {
# PYTHON_VERSION should be set explicitly from qmake command-line or via environment.
# F.e.: qmake PYTHON_VERSION=3.6 CONFIG+=release
# or set PYTHON_VERSION=2.7
!equals(PYTHON_CMD_FULL, $$PYTHON_CMD):warning("Missing desired PYTHON_VERSION, trying $${PYTHON_CMD} executable to guess the version.")
PYTHON_VERSION=$$PYTHON_VERSION_DETECTED
}

!equals(PYTHON_VERSION, $$PYTHON_VERSION_DETECTED){
error("Found Python version $$PYTHON_VERSION_DETECTED, but $$PYTHON_VERSION was requested")
}

PYTHON_VERSION_MAJOR=$$section(PYTHON_VERSION, ., 0, 0)
Expand All @@ -26,50 +63,50 @@ PYTHON_VERSION_MINOR=$$section(PYTHON_VERSION, ., 1, 1)
message(Using Python version $${PYTHON_VERSION})
}


# Python 2.x has problems:
# 1) https://wiki.gentoo.org/wiki/Project:Python/Strict_aliasing
# 2) deprecated implicit cast of string literals to char*
equals(PYTHON_VERSION_MAJOR, 2):gcc:QMAKE_CXXFLAGS *= -fno-strict-aliasing -Wno-error=write-strings
equals(PYTHON_VERSION_MAJOR, 2) {
gcc:QMAKE_CXXFLAGS *= -fno-strict-aliasing -Wno-write-strings
# Qt 5.4 adds this option, but this is not compatible with the Python API
msvc: QMAKE_CXXFLAGS -= -Zc:strictStrings

#We need to destinguish 64-bit build to add a workaround option
win32:isEmpty(QMAKE_TARGET.arch):system($$system_quote($${PYTHON_CMD}) -c \
$$system_quote(import sysconfig;exit(not sysconfig.get_platform().find(\'amd64\')))):DEFINES += MS_WIN64
}

contains(PKGCONFIG, "python.*"){
CONFIG += link_pkgconfig
PYTHON_PKGCONFIG = $$member($$unique($$find(PKGCONFIG, "python.*")), 1, 1)
# add rpath
PYTHON_LIBDIR = $$system($$pkgConfigExecutable() --libs-only-L $$PYTHON_PKGCONFIG)
QMAKE_RPATHDIR += $$replace(PYTHON_LIBDIR,-L,)
} else:macx:isEmpty(PYTHON_DIR){
} else:macx:isEmpty(PYTHON_CMD){
# for macx you need to have the Python development kit installed as framework
INCLUDEPATH += /System/Library/Frameworks/Python.framework/Headers
LIBS += -F/System/Library/Frameworks -framework Python
} else:win32 {
# for windows install a Python development kit or build Python yourself from the sources
# Make sure that you set the environment variable PYTHON_PATH to point to your
# python installation (or the python sources/header files when building from source).
# Make sure that you set the environment variable PYTHON_LIB to point to
# the directory where the python libs are located.
#
# When using the prebuild Python installer, this will be:
# set PYTHON_PATH = c:\Python26
# set PYTHON_LIB = c:\Python26\libs
#
# When using the python sources, this will be something like:
# set PYTHON_PATH = c:\yourDir\Python-2.6.1\
# set PYTHON_LIB = c:\yourDir\Python-2.6.1\PCbuild8\Win32

# check if debug or release
CONFIG(debug, debug|release) {
DEBUG_EXT = _d
} else {
DEBUG_EXT =
}

win32:INCLUDEPATH += $$(PYTHON_PATH)/PC $$(PYTHON_PATH)/include
win32:LIBS += $$(PYTHON_LIB)/python$${PYTHON_VERSION}$${DEBUG_EXT}.lib
INCLUDEPATH += $$system($$system_quote($${PYTHON_CMD}) -c \
$$system_quote(import sysconfig;print(\'\"%s\" \"%s\"\'%(sysconfig.get_paths()[\'include\'],sysconfig.get_paths()[\'platinclude\']))))

LIBS += -L$${PYTHON_PATH}libs
LIBS += -lpython$${PYTHON_VERSION_MAJOR}$${PYTHON_VERSION_MINOR}

# Hack for "CONFIG+=testcase" and 'make check' to add python's dll to PATH
deppath += $$PYTHON_PATH

} else:unix {
# on linux, python-config is used to autodetect Python.
# make sure that you have installed a matching python-dev package.

PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_VERSION}-config
PYTHON_CONFIG = $${PYTHON_PATH}python$${PYTHON_VERSION}-config
PYTHON_CONFIG_OPTIONS_LIBS = --libs
equals(PYTHON_VERSION_MAJOR, 3):!lessThan(PYTHON_VERSION_MINOR, 8) {
# Since 3.8 `--embed` is needed
Expand Down
11 changes: 9 additions & 2 deletions extensions/PythonQt_QtAll/PythonQt_QtAll.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )
TARGET = $$replace(TARGET, PythonXY, Python$${PYTHON_VERSION})

CONFIG += dll qt
CONFIG += qt strict_c++

!static:!staticlib {
CONFIG += dll
# Force linker to complain on undefined references for dll/so/dylib build when possible
QMAKE_LFLAGS_SHLIB += $$QMAKE_LFLAGS_NOUNDEF
}

DEFINES += PYTHONQT_QTALL_EXPORTS

Expand Down Expand Up @@ -74,6 +80,7 @@ defineTest(Xinclude) {
PythonQtCore {
DEFINES += PYTHONQT_WITH_CORE
Xinclude (com_trolltech_qt_core)
QT += core
}

PythonQtGui {
Expand All @@ -85,7 +92,7 @@ PythonQtGui {
PythonQtSvg {
DEFINES += PYTHONQT_WITH_SVG
Xinclude (com_trolltech_qt_svg)
QT +=svg
QT += svg
}

PythonQtSql {
Expand Down
12 changes: 12 additions & 0 deletions generated_cpp_59/com_trolltech_qt_core/com_trolltech_qt_core.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HEADERS += \
$$PWD/com_trolltech_qt_core0.h \
$$PWD/com_trolltech_qt_core1.h \
$$PWD/com_trolltech_qt_core2.h \
$$PWD/com_trolltech_qt_core3.h \

SOURCES += \
$$PWD/com_trolltech_qt_core0.cpp \
$$PWD/com_trolltech_qt_core1.cpp \
$$PWD/com_trolltech_qt_core2.cpp \
$$PWD/com_trolltech_qt_core3.cpp \
$$PWD/com_trolltech_qt_core_init.cpp
Loading