From 508023e0c77b0e92ee454f9771e4386e70fda359 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Thu, 26 Jul 2018 10:53:17 -0700 Subject: python: Fixup for Python API install directory The Python API should now be installed to `PREFIX/lib/pythonVER/dist-packages/uhd` where the PREFIX is set by CMake and the Python version is determined by the Python module `distutils`. This should match user expectations much more than the previous behavior. Behavior in Virtualenvs is unchanged. --- host/python/CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index 92c4daadc..124e16649 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -54,9 +54,21 @@ ADD_CUSTOM_COMMAND(OUTPUT ${TIMESTAMP_FILE} ADD_CUSTOM_TARGET(pyuhd_library ALL DEPENDS ${TIMESTAMP_FILE} pyuhd) IF(HAVE_PYTHON_VIRTUALENV) + # In virtualenvs, let setuptools do its thing INSTALL(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} -q install --force)") ELSE() - SET(UHD_PYTHON_DIR "lib/site-packages") - MESSAGE(STATUS "Utilizing the python install directory: ${CMAKE_INSTALL_PREFIX}/${UHD_PYTHON_DIR}") + # Otherwise, use distutils to determine the correct relative path for Python + # packages, and install to our prefix + IF(NOT DEFINED UHD_PYTHON_DIR) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "from __future__ import print_function;\ + from distutils import sysconfig;\ + print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'));" + OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE + ) + ENDIF(NOT DEFINED UHD_PYTHON_DIR) + file(TO_CMAKE_PATH ${UHD_PYTHON_DIR} UHD_PYTHON_DIR) + + MESSAGE(STATUS "Utilizing the python install directory: ${UHD_PYTHON_DIR}") INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/uhd DESTINATION ${UHD_PYTHON_DIR} COMPONENT pythonapi) -ENDIF() +ENDIF(HAVE_PYTHON_VIRTUALENV) -- cgit v1.2.3