aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2018-07-26 10:53:17 -0700
committerMartin Braun <martin.braun@ettus.com>2018-07-27 11:07:19 -0700
commit508023e0c77b0e92ee454f9771e4386e70fda359 (patch)
treebe5abd6ab5dcc9ff807da0fe267d9278104c7b16 /host
parent204d3c96a89ba2880c015ff1c018e5332140761f (diff)
downloaduhd-508023e0c77b0e92ee454f9771e4386e70fda359.tar.gz
uhd-508023e0c77b0e92ee454f9771e4386e70fda359.tar.bz2
uhd-508023e0c77b0e92ee454f9771e4386e70fda359.zip
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.
Diffstat (limited to 'host')
-rw-r--r--host/python/CMakeLists.txt18
1 files 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)