Skip to content

Commit

Permalink
Merge pull request #80 from paulinus/python-install-directory
Browse files Browse the repository at this point in the history
Detect where to install the python module
  • Loading branch information
laurentkneip authored Oct 25, 2018
2 parents a2ba31c + 528bf16 commit ff42bff
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ pybind11_add_module(pyopengv pyopengv.cpp)
target_link_libraries(pyopengv PRIVATE opengv)


# Find whether to install python libs in site-packages or dist-packages
execute_process( COMMAND
python -c "import distutils.sysconfig; print('dist-packages' if distutils.sysconfig.get_python_lib().endswith('dist-packages') else 'site-packages')"
# Find where to install python libs.
execute_process(COMMAND
${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print('/'.join(distutils.sysconfig.get_python_lib().split('/')[-3:]))"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)

set(PYTHON_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/lib/python2.7/${PYTHON_SITE_PACKAGES}"
"${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES}"
CACHE PATH "Path where to install pyopengv")

install(TARGETS pyopengv DESTINATION "${PYTHON_INSTALL_DIR}")

message(python executable ${PYTHON_EXECUTABLE})

0 comments on commit ff42bff

Please sign in to comment.