From d828b6a20d4996b2908ac085d8bda5599144be74 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Mon, 16 Mar 2015 11:28:39 +0100 Subject: python bindings: install modules to the dist-packages directory Use python to get the OS's directory name for dist-packages. The python bindings (low-level shared library and python proxy class) are then installed to that path, prefixed by the cmake install prefix. Signed-off-by: David Wagner --- bindings/python/CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'bindings') diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 3fef435..907741d 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -49,7 +49,19 @@ swig_link_libraries(PyPfw parameter ${PYTHON_LIBRARIES}) # class/interface class and as such cannot be destroyed. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable -DSWIG_PYTHON_SILENT_MEMLEAK") -install(TARGETS _PyPfw LIBRARY DESTINATION lib) + +# Find the python modules install path. +# plat_specific is needed because we are installing a shared-library python +# module and not only a pure python module. +# prefix='' makes get_python_lib return a relative path. +find_package(PythonInterp) +execute_process(COMMAND + ${PYTHON_EXECUTABLE} -c + "from distutils import sysconfig;\\ + print(sysconfig.get_python_lib(plat_specific=True, prefix=''))" + OUTPUT_VARIABLE PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) + +install(TARGETS _PyPfw LIBRARY DESTINATION ${PYTHON_MODULE_PATH}) # install the generated Python file as well -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PyPfw.py DESTINATION lib) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PyPfw.py DESTINATION ${PYTHON_MODULE_PATH}) -- cgit v1.1