mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
python: repair python installation with cmake
This commit is contained in:
1 parent
949751f632
commit
cc5c148fc1
1 file changed
+27
-32
+27
-32
@@ -12,41 +12,36 @@ add_custom_target(python
|
||||
DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml
|
||||
${CURRENT_SOURCE_DIR}/opendht/__init__.py
|
||||
${CURRENT_SOURCE_DIR}/opendht/aio.py)
|
||||
set(_pip_commands
|
||||
"${Python3_EXECUTABLE};-m;pip;install;--no-deps;--break-system-packages;${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${Python3_EXECUTABLE};-m;pip;install;--no-deps;${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"pip3;install;--no-deps;--break-system-packages;${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"pip;install;--no-deps;--break-system-packages;${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
install(CODE [[
|
||||
# Try different pip installation methods
|
||||
|
||||
set(_success FALSE)
|
||||
foreach(_cmd_list ${_pip_commands})
|
||||
string(REPLACE ";" " " _cmd_str "${_cmd_list}")
|
||||
message(STATUS "Attempting: ${_cmd_str}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${_cmd_list}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
OUTPUT_VARIABLE _pip_output
|
||||
ERROR_VARIABLE _pip_error
|
||||
RESULT_VARIABLE _pip_result)
|
||||
|
||||
if(_pip_result EQUAL 0)
|
||||
message(STATUS "Successfully installed Python package")
|
||||
message(STATUS "Output: ${_pip_output}")
|
||||
set(_success TRUE)
|
||||
break()
|
||||
install(CODE [[
|
||||
if(NOT Python3_EXECUTABLE)
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
endif()
|
||||
if(NOT Python3_EXECUTABLE)
|
||||
message(WARNING "Skipping Python package install: Python interpreter not found.")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip --version
|
||||
OUTPUT_QUIET
|
||||
ERROR_QUIET
|
||||
RESULT_VARIABLE _pip_check)
|
||||
if(NOT _pip_check EQUAL 0)
|
||||
message(WARNING "Skipping Python package install: pip not available for ${Python3_EXECUTABLE}.")
|
||||
else()
|
||||
message(WARNING "Command failed with code ${_pip_result}")
|
||||
message(WARNING "Output: ${_pip_output}")
|
||||
message(WARNING "Error: ${_pip_error}")
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install --no-deps --break-system-packages .
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python
|
||||
OUTPUT_VARIABLE _pip_output
|
||||
ERROR_VARIABLE _pip_error
|
||||
RESULT_VARIABLE _pip_result)
|
||||
|
||||
if(_pip_result EQUAL 0)
|
||||
message(STATUS "Successfully installed Python package")
|
||||
message(STATUS "Output: ${_pip_output}")
|
||||
else()
|
||||
message(WARNING "pip install failed (code: ${_pip_result})\nOutput: ${_pip_output}\nError: ${_pip_error}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT _success)
|
||||
message(FATAL_ERROR "All pip install attempts failed. Check that pip is available and the wheel was built correctly.")
|
||||
endif()
|
||||
]])
|
||||
if (OPENDHT_TOOLS)
|
||||
|
||||
Reference in new issue
Block a user