Skip to content

Commit ce02148

Browse files
authored
Update CMakeLists.txt to better detect Python lib site-packages location
1 parent f16a085 commit ce02148

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ endif()
284284
# Find SWIG
285285
find_package(SWIG 4.0 COMPONENTS python)
286286
if(SWIG_FOUND)
287+
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
288+
if(NOT DEFINED PYTHON_SITE_PACKAGES)
289+
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
290+
endif()
287291
# https://discourse.cmake.org/t/find-package-python3-is-not-finding-the-correct-python/10563/8
288292
set(Python3_FIND_STRATEGY LOCATION)
289293
set(Python3_FIND_UNVERSIONED_NAMES FIRST)

0 commit comments

Comments
 (0)