Skip to content

Commit d0f3330

Browse files
committed
[cmake] Compute Python install dir without Python_SITEARCH (fix Debian)
On Debian Python_SITEARCH points at dist-packages, so the clair Python module installed there instead of the site-packages layout used across the TRIQS stack. Select the layout via BUILD_DEBIAN_PACKAGE instead, matching h5/cpp2py. See TRIQS/triqs#1022 Assisted-by: Claude <[email protected]>
1 parent b34ebd8 commit d0f3330

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ endif()
5858
# Build static libraries by default
5959
option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF)
6060

61+
# Build a Debian package; also selects the dist-packages Python install layout
62+
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
63+
6164
# Export the list of compile-commands into compile_commands.json
6265
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6366

@@ -109,7 +112,14 @@ include(GNUInstallDirs)
109112
# Python
110113
message(STATUS "-------- Python detection -------------")
111114
find_package(Python COMPONENTS Interpreter Development NumPy)
112-
string(REGEX REPLACE "/.*/lib" "lib" PYTHON_LIB_DEST_ROOT ${Python_SITEARCH})
115+
# Python module install location, consistent with the rest of the TRIQS stack
116+
# (BUILD_DEBIAN_PACKAGE may be set by the parent project). Not derived from
117+
# Python_SITEARCH, which points at dist-packages on Debian (see TRIQS/triqs#1022).
118+
if(BUILD_DEBIAN_PACKAGE)
119+
set(PYTHON_LIB_DEST_ROOT lib/python${Python_VERSION_MAJOR}/dist-packages)
120+
else()
121+
set(PYTHON_LIB_DEST_ROOT lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
122+
endif()
113123
set(PYTHON_LIB_DEST_ROOT ${PYTHON_LIB_DEST_ROOT} CACHE PATH "Python library destination")
114124

115125
# #############
@@ -137,7 +147,6 @@ add_subdirectory(share)
137147
# #############
138148
# Debian Package
139149

140-
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
141150
if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT)
142151
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
143152
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")

0 commit comments

Comments
 (0)