Skip to content

Find also Python3 with find_package(PythonInterp)

Friedrich W. H. Kossebau requested to merge work/kossebau/buildwithpython3 into 3.2

At least with openSUSE TW searching with a version given seems to restrict the versions accepted to the major version. So if only python3 is available, searching for 2.6 yields no results. Given 2.6 is stone-age old, we can assume any found version is good enough these days.

Cmp. https://build.kde.org/job/Calligra/job/kdb/job/stable-kf5-qt5%20SUSEQt5.14/ latest job is run after the openSUSE image was updated and (unplanned sideeffect) python2 was dropped from the image due to nothing pulling it in any longer. (and of course thus also breaks Calligra dependency build, https://build.kde.org/view/Failing/job/Administration/job/Dependency%20Build%20Calligra%20stable-kf5-qt5%20SUSEQt5.14/ ).

And it fails with the given log because REQUIRED is only to set as package type for PythonInterp, but not as flag to the find_package(PythonInterp) call, so cmake goes on into the for loop and processes execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/sdc.py [...]) which still results in sdc.py being executed (at least tried), because it has the executable flag set and a shebang. Just, on openSUSE TW this fails without python2 installed with some /usr/bin/env: 'python': No such file or directory and as the exit value is not checked, cmake continues. And only later fails when it gets to ecm_generate_headers passing it the names of the (not) generated headers by ${kdb_GENERATED_SHARED_DATA_CLASS_BASENAMES}, over which ecm_generate_headers then throws up.

"#!/usr/bin/env python" as shebang seems a principle problem with lots of incompatible solutions, cmp. https://www.python.org/dev/peps/pep-0394/ . But by calling the interpreter here we do not have to care.

I guess at least in master branch one could also go Python3-only now, but different story, not in scope of this fix.

Merge request reports