Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set PYTHON_INCLUDE_DIR and PYTHON_LIBRARY during installation #222

Conversation

thinking-tower
Copy link
Contributor

@thinking-tower thinking-tower commented May 27, 2021

cc @unexploredtest, @axsaucedo, Superchunk. This should fix #221.

Description

Finding Python for CMake is a known issue. This PR from PyTorch, while not directly related to fixing Python installation issues, shows a tried-and-tested way to help CMake find Python. In particular, the following lines are of interest:

# Dependencies.cmake
pycmd_no_exit(_py_inc _exitcode "import sysconfig; print(sysconfig.get_path('include'))")
pycmd_no_exit(_py_lib _exitcode "import sysconfig; print(sysconfig.get_path('stdlib'))")
# setup.py
cmake_python_library = "{}/{}".format(
        sysconfig.get_config_var("LIBDIR"),
        sysconfig.get_config_var("INSTSONAME"))
cmake_python_include_dir = sysconfig.get_path("include")

I opted for the first option, as the second option gave an incorrect directory on my machine (but the installation still worked).

Notes

It's worth noting that FindPython3 (for CMake 3.12+) does a similar thing. See here

@axsaucedo axsaucedo merged commit dccbe4a into KomputeProject:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python macOS issue (Symbol not found: __PyThreadState_Current ... Expected in: flat namespace)
2 participants