diff options
author | karel <5636152+karel@users.noreply.github.com> | 2018-10-25 12:18:47 +0300 |
---|---|---|
committer | Marcus Müller <marcus.mueller@ettus.com> | 2018-11-01 16:15:46 +0100 |
commit | 0d6aa71a114a2d2c6be95bc59c45a621bf053c82 (patch) | |
tree | 9384b1b6b7e85c4ed710a3e2a88b5efae8d24407 /cmake | |
parent | 8836b51f82132285de93620844180a89715157ae (diff) |
cmake: fix finding Python packages' installation directory
Removes the hard-coded 'dist-packages' because it's Debian specific and
leads to problems on distributions which use 'site-packages' (e.g. Arch
and Gentoo). This commit still retains the current behavior in virtual
environments without 'getsitepackages'.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/GrPython.cmake | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake index 49a351d3a7..d48915bebe 100644 --- a/cmake/Modules/GrPython.cmake +++ b/cmake/Modules/GrPython.cmake @@ -93,12 +93,12 @@ endmacro(GR_PYTHON_CHECK_MODULE) ######################################################################## if(NOT DEFINED GR_PYTHON_DIR) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c " -import os -import sys -if os.name == 'posix': - print(os.path.join('lib', 'python' + sys.version[:3], 'dist-packages')) -if os.name == 'nt': - print(os.path.join('Lib', 'site-packages')) +try: + from site import getsitepackages + print(getsitepackages()[0]) +except ImportError: + from distutils.sysconfig import get_python_lib + print(get_python_lib()) " OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) endif() |