Thanks a lot, this is very helpful. It seems a strange decision that the now-preinstalled Python 3 version (3.5) is lower than before (3.6 and 3.7), but I’m sure there are reasons, and at least that explains the problem. I guess I’ll have to install Python 3.7 as part of the ‘install’ script. I’ll report back when I have something working.
After a lot of trial and error, including trying to install Python 3.7 via the deadsnakes PPA rather than pyenv (see https://stackoverflow.com/a/37660551/1951907), what worked in my case was to keep using pyenv, but I had to update pyenv first. Here are my steps:
See https://github.com/pyenv/pyenv#upgrading for the official way to update pyenv.
E.g. you can save an extra checkout with fetch instead of pull, and I don’t see a use for git branch if you checkout something else afterwards anyway.
As an aside, specifying -DPYTHON_EXECUTABLE is enough for CMake to use a Python installation IIRC, and if you pyenv global it before that, it’s going to be at which python (the shim) or pyenv which python (the real executable), no need to hardcode.
Thanks for the added info. Using fetch instead of pull seems like a better idea indeed. The branch call was suggested by git after git pull complained that the current branch didn’t have an upstream. I’ll remove it if I use fetch.
Regarding the explicit -DPYTHON_EXECUTABLE, -DPYTHON_LIBRARY, and -DPYTHON_INCLUDE_DIR, I remember having problems in the past if I didn’t specify all of them, reason why I now always do it like this at least in CI builds, since I don’t have to type it each time anyway. I think the main problem is that even if CMake finds the correct -DPYTHON_EXECUTABLE thanks to pyenv global, it still sometimes fails to detect the correct -DPYTHON_LIBRARY, because two python installations might actually have the same --prefix. Zen of Python: Explicit is better than implicit