build/python: replace calls to setup.py

This commit is contained in:
Adrien Béraud committed 2025-08-17 22:08:13 -04:00
1 parent a051b391a8
commit 5fe0dad574
2 files changed
+18 -12

No files matched your search

+15 -9
View File
@@ -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()
endif()
+3 -3
View File
@@ -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