@@ -12,17 +12,41 @@ add_custom_target(python
12
12
DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml
13
13
${CURRENT_SOURCE_DIR} /opendht/__init__.py
14
14
${CURRENT_SOURCE_DIR} /opendht/aio.py)
15
+ set (_pip_commands
16
+ "${Python3_EXECUTABLE} ;-m;pip;install;--no-deps;--break-system-packages;${CMAKE_CURRENT_BINARY_DIR} "
17
+ "${Python3_EXECUTABLE} ;-m;pip;install;--no-deps;${CMAKE_CURRENT_BINARY_DIR} "
18
+ "pip3;install;--no-deps;--break-system-packages;${CMAKE_CURRENT_BINARY_DIR} "
19
+ "pip;install;--no-deps;--break-system-packages;${CMAKE_CURRENT_BINARY_DIR} " )
15
20
16
21
install (CODE [[
17
- execute_process(
18
- COMMAND "${Python3_EXECUTABLE}" -m pip install --no-deps --break-system-packages "${CMAKE_CURRENT_BINARY_DIR}"
19
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
20
- OUTPUT_VARIABLE _pip_output
21
- ERROR_VARIABLE _pip_output
22
- RESULT_VARIABLE _pip_result)
23
- message(STATUS ${_pip_output})
24
- if(NOT _pip_result EQUAL 0)
25
- message(FATAL_ERROR "pip install failed with code ${_pip_result}")
22
+ # Try different pip installation methods
23
+
24
+ set(_success FALSE)
25
+ foreach(_cmd_list ${_pip_commands})
26
+ string(REPLACE ";" " " _cmd_str "${_cmd_list}")
27
+ message(STATUS "Attempting: ${_cmd_str}")
28
+
29
+ execute_process(
30
+ COMMAND ${_cmd_list}
31
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
32
+ OUTPUT_VARIABLE _pip_output
33
+ ERROR_VARIABLE _pip_error
34
+ RESULT_VARIABLE _pip_result)
35
+
36
+ if(_pip_result EQUAL 0)
37
+ message(STATUS "Successfully installed Python package")
38
+ message(STATUS "Output: ${_pip_output}")
39
+ set(_success TRUE)
40
+ break()
41
+ else()
42
+ message(WARNING "Command failed with code ${_pip_result}")
43
+ message(WARNING "Output: ${_pip_output}")
44
+ message(WARNING "Error: ${_pip_error}")
45
+ endif()
46
+ endforeach()
47
+
48
+ if(NOT _success)
49
+ message(FATAL_ERROR "All pip install attempts failed. Check that pip is available and the wheel was built correctly.")
26
50
endif()
27
51
]])
28
52
if (OPENDHT_TOOLS)
0 commit comments