From 5fe0dad5747393a4cee9b772d622e274fd6fd312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <> Date: Sun, 17 Aug 2025 00:20:59 -0400 Subject: [PATCH] build/python: replace calls to setup.py --- python/CMakeLists.txt | 24 +++++++++++++++--------- python/Makefile.am | 6 +++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e3199e2f..c8fbdd56 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,19 +1,25 @@ - set(CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) configure_file(setup.py.in setup.py) configure_file(pyproject.toml pyproject.toml COPYONLY) -add_custom_target(python ALL - COMMAND python3 setup.py build_ext --inplace +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +add_custom_target(python + COMMAND ${Python3_EXECUTABLE} -m build . DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml) -add_custom_target(dist - COMMAND python3 -m build - DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml) - -install(CODE "execute_process(COMMAND python3 setup.py install --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") +install(CODE [[ + execute_process( + COMMAND "${Python3_EXECUTABLE}" -m pip install --no-deps . + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + RESULT_VARIABLE _pip_result + OUTPUT_FILE "toto" ) + if(NOT _pip_result EQUAL 0) + message(FATAL_ERROR "pip install failed with code ${_pip_result}") + endif() +]]) if (OPENDHT_TOOLS) install(PROGRAMS tools/dhtcluster.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME dhtcluster) -endif() \ No newline at end of file +endif() diff --git a/python/Makefile.am b/python/Makefile.am index 98aeed41..b5209fea 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -8,7 +8,7 @@ noinst_HEADERS = \ PYTHON_INSTALL_RECORD = $(builddir)/install_record.txt pybuild.stamp: - LDFLAGS="-L$(top_srcdir)/src/.libs" $(PYTHON) setup.py build_ext --inplace + LDFLAGS="-L$(top_srcdir)/src/.libs" $(PYTHON) -m build . echo stamp > pybuild.stamp CLEANFILES = pybuild.stamp @@ -18,7 +18,8 @@ clean-local: rm -rf $(builddir)/build $(builddir)/*.so $(PYTHON_INSTALL_RECORD) install-exec-local: - $(PYTHON) setup.py install --root=$(DESTDIR)/ --record $(PYTHON_INSTALL_RECORD) + $(PYTHON) -m pip install --no-deps --no-build-isolation . \ + --root=$(DESTDIR)/ --prefix=$(prefix) rm -rf $(builddir)/build if HAVE_PIP @@ -27,4 +28,3 @@ uninstall-local: endif endif -