Skip to content

Commit 9c264e1

Browse files
author
Adrien Béraud
committed
python: add debug information for python install
1 parent deee57b commit 9c264e1

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

python/CMakeLists.txt

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,41 @@ add_custom_target(python
1212
DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml
1313
${CURRENT_SOURCE_DIR}/opendht/__init__.py
1414
${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}")
1520

1621
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.")
2650
endif()
2751
]])
2852
if (OPENDHT_TOOLS)

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "Cython", "build"]
2+
requires = ["setuptools", "wheel", "Cython"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.cibuildwheel]

0 commit comments

Comments
 (0)