Skip to content

Commit

Permalink
Merge pull request artivis#259 from traversaro/patch-6
Browse files Browse the repository at this point in the history
Permit to specify Python package install dir with MANIFPY_PKGDIR
  • Loading branch information
artivis authored Jul 6, 2023
2 parents bc1e90f + 905d893 commit 64f6e0c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ set_property(TARGET manifpy PROPERTY CXX_EXTENSIONS OFF)

if (CALL_FROM_SETUP_PY)
# cmake-build-extension sets the full absolute path as CMAKE_INSTALL_PREFIX.
set(MANIFPY_PKGDIR "${CMAKE_INSTALL_PREFIX}")
set(MANIFPY_INSTDIR "${CMAKE_INSTALL_PREFIX}")
else()
# Permit to specify MANIFPY_INSTDIR as an option
elseif(NOT DEFINED MANIFPY_PKGDIR)
# 'distutils.sysconfig.get_python_lib' returns the absolute path of Python
# by default a global location managed by the distro e.g. /usr/lib/python.
#
Expand All @@ -40,7 +42,10 @@ else()
${PYTHON_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])"
OUTPUT_VARIABLE _PYTHON_SITE_PACKAGE OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(MANIFPY_INSTDIR "${_PYTHON_SITE_PACKAGE}/manifpy")
set(MANIFPY_PKGDIR "${_PYTHON_SITE_PACKAGE}")
set(MANIFPY_INSTDIR "${MANIFPY_PKGDIR}/manifpy")
else()
set(MANIFPY_INSTDIR "${MANIFPY_PKGDIR}/manifpy")
endif()

message(STATUS "Installing manifpy in ${MANIFPY_INSTDIR}")
Expand Down Expand Up @@ -77,5 +82,5 @@ if (NOT CALL_FROM_SETUP_PY)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/INSTALLER "cmake\n")
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/METADATA" "${CMAKE_CURRENT_BINARY_DIR}/INSTALLER"
DESTINATION ${PYTHON_PREFIX}/manifpy-${PROJECT_VERSION}.dist-info)
DESTINATION ${MANIFPY_PKGDIR}/manifpy-${PROJECT_VERSION}.dist-info)
endif()

0 comments on commit 64f6e0c

Please sign in to comment.