cklb / pymoskito

Python based modular control simulation kickass toolbox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Version

TanDro opened this issue · comments

The following code

c_make_lists += "set (Python_FIND_VIRTUALENV STANDARD)\n"
py_ver = platform.python_version()
c_make_lists += "find_package(Python {} EXACT REQUIRED " \
"COMPONENTS Interpreter Development)\n\n" \
"".format(py_ver)

leads to the following error

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find Python: Found unsuitable version "3.8", but required is
  exact version "3.8.10" (found _Python_EXECUTABLE-NOTFOUND)

during compilation in Ubuntu like setups (Ubuntu, Wsl) and with a Windows Visual Studio setup.

I have had good experience with

c_make_lists += "set (Python_FIND_VIRTUALENV STANDARD)\n"
c_make_lists += "find_package(Python REQUIRED " \
                "COMPONENTS Interpreter Development)\n\n"

Hey,
I introduced that rather strict version checking since CMake in the CI tests always managed to find the wrong one.
It seems like the behavior changed over various CMake versions, with v3.20 in the CI or v3.21.1 on my machine its working.
What happens if you only get rid of the `EXACT' keyword but keep the version in there?

Hey,

I have found a variant that works on all platforms I can test on.

  c_make_lists += "set (Python_FIND_VIRTUALENV STANDARD)\n"
  c_make_lists += "find_package(Python {}.{} EXACT REQUIRED " \
                  "COMPONENTS Interpreter Development)\n\n" \
                  "".format(sys.version_info[0], sys.version_info[1])

A very nice solution. The CI toolchain seems to like it: https://github.com/cklb/pymoskito/actions/runs/1147487003.

Please report back if the issue can be closed.

All right, I tested it on three other machines and it worked fine. I close the issue.