diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-04-25 12:46:36 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-04-27 09:35:01 +0000 |
commit | e453be82f510303e41a24c0093bd03c7f8374f75 (patch) | |
tree | b38160e341c96fa4cda4b20577c812affcdb2b90 /configure.pri | |
parent | 3b24c024f2606cd93b1f397338f349582003c2ce (diff) |
Make python2 usage more robust
After configuring Qt there will be an error message if a suitable python
version could not be found.
Add python2 configure test that
- first looks for python2 in PATH
- then looks for python in PATH
- checks the Python version
- stores the result in QMAKE_PYTHON2
Use $$QMAKE_PYTHON2 everywhere where we call python.
Pass $$QMAKE_PYTHON2 to gn for its exec_script feature.
Task-number: QTBUG-60164
Change-Id: I33de1273cbd20a787b3c8889d35280784dbcd5ae
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'configure.pri')
-rw-r--r-- | configure.pri | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/configure.pri b/configure.pri index 23f31686e..ce36642bb 100644 --- a/configure.pri +++ b/configure.pri @@ -1,5 +1,46 @@ equals(QMAKE_HOST.os, Windows): EXE_SUFFIX = .exe +defineTest(isPythonVersionSupported) { + python = $$system_quote($$system_path($$1)) + python_version = $$system('$$python -c "import sys; print(sys.version_info[0:3])"') + python_version ~= s/[()]//g + python_version = $$split(python_version, ',') + python_major_version = $$first(python_version) + greaterThan(python_major_version, 2) { + qtLog("Python version 3 is not supported by Chromium.") + return(false) + } + python_minor_version = $$member(python_version, 1) + python_patch_version = $$member(python_version, 2) + greaterThan(python_major_version, 1): greaterThan(python_minor_version, 6): greaterThan(python_patch_version, 4): return(true) + qtLog("Unsupported python version: $${python_major_version}.$${python_minor_version}.$${python_patch_version}.") + return(false) +} + +defineTest(qtConfTest_detectPython2) { + python = $$qtConfFindInPath("python2") + isEmpty(python) { + qtLog("'python2' not found in PATH. Checking for 'python'.") + python = $$qtConfFindInPath("python$$EXE_SUFFIX") + } + isEmpty(python) { + qtLog("'python$$EXE_SUFFIX' not found in PATH. Giving up.") + return(false) + } + !isPythonVersionSupported($$python) { + qtLog("A suitable Python 2 executable could not be located.") + return(false) + } + + # Make tests.python2.location available in configure.json. + $${1}.location = $$clean_path($$python) + export($${1}.location) + $${1}.cache += location + export($${1}.cache) + + return(true) +} + defineTest(qtConfTest_detectNinja) { ninja = $$qtConfFindInPath("ninja$$EXE_SUFFIX") !isEmpty(ninja) { |