-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
python-install.cmake.in
40 lines (37 loc) · 1.13 KB
/
python-install.cmake.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
if(NOT UNIX)
execute_process(
WORKING_DIRECTORY @PROJECT_BINARY_DIR@/python
COMMAND @Python3_EXECUTABLE@ -m pip install
--find-links=dist @PYTHON_PROJECT@==@PROJECT_VERSION@
)
return()
endif()
if(DEFINED ENV{DESTDIR})
# If DESTDIR is not absolute path, make it relative to @PROJECT_BINARY_DIR@
# like any install() command.
if(IS_ABSOLUTE $ENV{DESTDIR})
set(ROOT "--root='$ENV{DESTDIR}'")
else()
set(ROOT "--root='@PROJECT_BINARY_DIR@/$ENV{DESTDIR}'")
endif()
else()
set(ROOT "")
endif()
# Check if we have system Python on Debian/Ubuntu, if so tell setuptools
# to use the deb layout (dist-packages instead of site-packages).
execute_process(
COMMAND "@Python3_EXECUTABLE@" -c "import sys; sys.stdout.write(sys.path[-1])"
OUTPUT_VARIABLE Python_STDLIB_DIR
)
if(Python_STDLIB_DIR MATCHES ".*/dist-packages$")
set(SETUPTOOLS_INSTALL_LAYOUT "--install-layout=deb")
else()
set(SETUPTOOLS_INSTALL_LAYOUT "")
endif()
execute_process(
WORKING_DIRECTORY @PROJECT_BINARY_DIR@/python
COMMAND "@Python3_EXECUTABLE@" setup.py install
${ROOT}
--prefix="@CMAKE_INSTALL_PREFIX@"
${SETUPTOOLS_INSTALL_LAYOUT}
)