Does CMake support Python3?

前端 未结 3 1379
春和景丽
春和景丽 2021-01-08 00:31

I am not able to build a Python wrapper module for my C library via CMake and Swig for Python3. Everything works fine for Python2.x but it looks like CMake cannot find Pytho

相关标签:
3条回答
  • 2021-01-08 01:08

    Can you make sure your build directory is clean? I had the exact same issue and after cleaning the dir it worked.

    0 讨论(0)
  • 2021-01-08 01:12

    CMake 3.12 should help you with your issue. Citing the release notes:

    New “FindPython3” and “FindPython2” modules, as well as a new “FindPython” module, have been added to provide a new way to locate python environments.

    0 讨论(0)
  • 2021-01-08 01:16

    I kind of solved the problem by setting the python version manually. This is not really recommendable but it works for now (note that you have to use your own installation path of the python version you want to use):

    SET(PYTHON_INCLUDE_PATH /usr/include/python3.2mu)
    SET(PYTHON_LIBRARIES /usr/lib/libpython3.2mu.so)
    SET(PYTHON_EXECUTABLE /usr/bin/python3.2mu)
    SET(PYTHON_INCLUDE_DIR  /usr/include/python3.2mu)
    
    0 讨论(0)
提交回复
热议问题