-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpython-wheel-globals.cmake
More file actions
72 lines (67 loc) · 2.31 KB
/
python-wheel-globals.cmake
File metadata and controls
72 lines (67 loc) · 2.31 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
# Some RPATH setup for macOS
if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};@loader_path")
# Check for delocate (required for proper library dependency handling)
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c "import delocate"
RESULT_VARIABLE DELOCATE_CHECK
OUTPUT_QUIET
ERROR_QUIET
)
if(NOT DELOCATE_CHECK EQUAL 0)
message(FATAL_ERROR "delocate is required for macOS wheel building to handle library dependencies correctly. Install with: pip install delocate")
endif()
endif()
# Guess python wheel filename infixes (abi + platform) to be used
# with binary python module dependency URLs.
#
# Example:
# - "https://my.url/packages/pkg/1.0/pkg-1.0${PY_WHEEL_C_INFIX}.whl"
#
# See:
# - https://www.python.org/dev/peps/pep-0427/#file-name-convention
# - https://github.com/pypa/wheel/blob/master/src/wheel/bdist_wheel.py#L43
set(PY_WHEEL_C_ABI "cp${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}-cp${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
if (WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PY_WHEEL_PLATFORM "win_amd64")
else()
set(PY_WHEEL_PLATFORM "win_x86")
endif()
elseif (APPLE)
execute_process(
COMMAND
"${Python3_EXECUTABLE}"
"-c" "import platform; print('_'.join(platform.mac_ver()[0].split('.')[:2]))"
OUTPUT_VARIABLE MACOS_VER
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND
"${Python3_EXECUTABLE}"
"-c" "import platform; print(platform.machine())"
OUTPUT_VARIABLE MACHINE_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(MACHINE_ARCH STREQUAL "arm64")
set(PY_WHEEL_PLATFORM "macosx_${MACOS_VER}_arm64")
else()
set(PY_WHEEL_PLATFORM "macosx_${MACOS_VER}_x86_64")
endif()
else()
execute_process(
COMMAND
"${Python3_EXECUTABLE}"
"-c" "import platform; print(platform.machine())"
OUTPUT_VARIABLE MACHINE_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(MACHINE_ARCH STREQUAL "aarch64")
set(PY_WHEEL_PLATFORM "linux_aarch64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PY_WHEEL_PLATFORM "linux_x86_64")
else()
set(PY_WHEEL_PLATFORM "linux_i686")
endif()
endif()
set(PY_WHEEL_C_INFIX "-${PY_WHEEL_C_ABI}-${PY_WHEEL_PLATFORM}")