diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-05-01 10:53:00 -0700 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-05-07 10:30:58 -0500 |
commit | 75b7991378e3f465f9d91cba597d98ee5b9054ed (patch) | |
tree | b3fb07771adf5ee391dfc8c938fc10a496b7dd48 /host | |
parent | 4e775027871a7676bb49076cf56638aef2529bfe (diff) | |
download | uhd-75b7991378e3f465f9d91cba597d98ee5b9054ed.tar.gz uhd-75b7991378e3f465f9d91cba597d98ee5b9054ed.tar.bz2 uhd-75b7991378e3f465f9d91cba597d98ee5b9054ed.zip |
python: Fix RPATH for the Python library
On UNIX systems, CMake will set the RPATH of the Python library to the
build directory, which is very helpful because it allows unit and other
tests to be executed from within the build directory.
On installation, the RPATH is removed, but only if install(TARGETS) is
used, which we were not, thus resulting in incorrect RPATHs.
This would surface as a bug, too. Calling uhd.get_lib_path() would
always point to the build directory, thus resulting in no FPGA images
being found automatically, e.g. when running a B200 through the Python
API.
This change installs the Python .so file separately, using the correct
CMake mechanisms.
Diffstat (limited to 'host')
-rw-r--r-- | host/python/CMakeLists.txt | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index a4929b977..0990e2582 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -43,7 +43,11 @@ else() if(${PYTHON_EXTENSION_SUFFIX} STREQUAL "None") set(PYTHON_EXTENSION_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX}) endif() - set_target_properties(pyuhd PROPERTIES PREFIX "lib" SUFFIX ${PYTHON_EXTENSION_SUFFIX}) + set_target_properties(pyuhd + PROPERTIES + PREFIX "lib" + SUFFIX ${PYTHON_EXTENSION_SUFFIX} + ) endif(WIN32) target_include_directories(pyuhd PUBLIC ${PYTHON_NUMPY_INCLUDE_DIR} @@ -104,5 +108,22 @@ else() 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) + # CMake will create an up-to-date copy of the entire Python module within + # the build directory. Instead of using setuptools, we use distutils (above) + # to figure out the destination path, and then we simply copy this module + # recursively into its final destination. + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/uhd + DESTINATION ${UHD_PYTHON_DIR} + COMPONENT pythonapi + ) + # On Linux/Unix systems, we must properly install the library file, though. + # install(DIRECTORY) will treat the .so file like any other file, which + # means it won't update its RPATH, and thus the RPATH would be stuck to the + # build directory. + if(UNIX) + install(TARGETS pyuhd + DESTINATION ${UHD_PYTHON_DIR}/uhd + ) + endif(UNIX) endif(HAVE_PYTHON_VIRTUALENV) |