Skip to content

Commit 65faa4b

Browse files
jcfrmrbean-bremen
authored andcommitted
chore(PythonQtPythonInclude, build/python.prf): Report error if using Python 2.x
1 parent 36bb187 commit 65faa4b

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

build/python.prf

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@ PYTHON_VERSION_MINOR=$$section(PYTHON_VERSION, ., 1, 1)
2525
message(Using Python version $${PYTHON_VERSION})
2626
}
2727

28-
29-
# Python 2.x has problems:
30-
# 1) https://wiki.gentoo.org/wiki/Project:Python/Strict_aliasing
31-
# 2) deprecated implicit cast of string literals to char*
28+
# Python 3.x is required
3229
equals(PYTHON_VERSION_MAJOR, 2) {
33-
gcc:QMAKE_CXXFLAGS *= -fno-strict-aliasing -Wno-write-strings
34-
# Qt 5.4 adds this option, but this is not compatible with the Python API
35-
msvc: QMAKE_CXXFLAGS -= -Zc:strictStrings
30+
error("Python >= 3.x is required")
3631
}
3732

3833
contains(PKGCONFIG, "python.*"){
@@ -73,13 +68,6 @@ contains(PKGCONFIG, "python.*"){
7368
error("PYTHON_PATH must be set to correct folder with \\libs and \\include subfolders ")
7469
}
7570

76-
#We need to destinguish 64-bit build to add a workaround option
77-
#The only known problematic case is MinGW with external (MSVC-built) Python2
78-
mingw:equals(PYTHON_VERSION_MAJOR, 2): isEmpty(QMAKE_TARGET.arch):system(\
79-
$$system_quote($$system_path($${PYTHON_PATH}/python.exe)) -c \
80-
$$system_quote(import sysconfig;exit(0 if 0 <= sysconfig.get_platform().find(\'win-amd64\') else 1))\
81-
):DEFINES += MS_WIN64
82-
8371
INCLUDEPATH += $$shell_path($${PYTHON_PATH}/include)
8472

8573
LIBS += $$shell_path(-L$${PYTHON_PATH}/libs)

src/PythonQtPythonInclude.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,14 @@
117117
#undef PYTHONQT_RESTORE_KEYWORDS
118118
#endif
119119

120-
#if PY_MAJOR_VERSION >= 3
120+
#if PY_MAJOR_VERSION < 3
121+
#error "PythonQt requires Python >= 3.x"
122+
#endif
123+
121124
#define PY3K
122125
// Helper defines to facilitate porting
123126
#define PyString_FromString PyUnicode_FromString
124127

125-
#else
126-
// Defines to use Python 3 names in Python 2 code
127-
#define PyBytes_Type PyString_Type
128-
#define PyBytes_GET_SIZE PyString_GET_SIZE
129-
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
130-
#endif
131-
132128
// Avoid clashes with libstdc++ <locale> by undefining ctype macros
133129
// that CPython may introduce on macOS when the UTF-8 ctype quirk is enabled.
134130
// (_PY_PORT_CTYPE_UTF8_ISSUE is defined by CPython’s pyport.h; we apply these

0 commit comments

Comments
 (0)