Skip to content

Commit 8c69584

Browse files
committed
python: Use pypa/installer instead of use setup.py directly
running install /usr/lib/python3.13/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() /usr/lib/python3.13/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` and ``easy_install``. Instead, use pypa/build, pypa/installer or other standards-based tools. See pypa/setuptools#917 for details. ******************************************************************************** !! self.initialize_options() Link: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html Signed-off-by: Rong Tao <[email protected]>
1 parent 1f63ae6 commit 8c69584

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ if(CMAKE_USE_LIBBPF_PACKAGE)
120120
find_package(LibBpf)
121121
endif()
122122

123+
if(NOT PYTHON_CMD)
124+
set(PYTHON_CMD "python3")
125+
endif()
126+
123127
if(NOT PYTHON_ONLY)
124128
find_package(LLVM REQUIRED CONFIG)
125129
message(STATUS "Found LLVM: ${LLVM_INCLUDE_DIRS} ${LLVM_PACKAGE_VERSION} (Use LLVM_ROOT envronment variable for another version of LLVM)")

cmake/CmakeUninstall.cmake.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ endforeach()
2626
endfunction()
2727

2828
UninstallManifest("@CMAKE_BINARY_DIR@/install_manifest.txt")
29-
UninstallManifest("@CMAKE_BINARY_DIR@/install_manifest_python_bcc.txt")
29+
foreach(PY_CMD ${PYTHON_CMD})
30+
execute_process(COMMAND ${PY_CMD} -m pip uninstall -y bcc)
31+
endforeach()

src/python/CMakeLists.txt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# Copyright (c) PLUMgrid, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License")
33

4-
if(NOT PYTHON_CMD)
5-
set(PYTHON_CMD "python3")
6-
endif()
7-
8-
if(EXISTS "/etc/debian_version" AND NOT PY_SKIP_DEB_LAYOUT)
9-
set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
10-
endif()
11-
124
file(GLOB_RECURSE PYTHON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
135
${CMAKE_CURRENT_SOURCE_DIR}/*.py)
146
file(GLOB_RECURSE PYTHON_INCLUDES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -27,13 +19,13 @@ foreach(PY_CMD ${PYTHON_CMD})
2719
configure_file(${PY_INC} ${PY_DIRECTORY}/${PY_INC_REPLACED} @ONLY)
2820
endforeach()
2921

30-
set(PIP_INSTALLABLE "${PY_DIRECTORY}/dist/bcc-${REVISION}.tar.gz")
22+
set(PIP_INSTALLABLE "${PY_DIRECTORY}/dist/bcc-${REVISION}-py3-none-any.whl")
3123
add_custom_command(
3224
OUTPUT ${PIP_INSTALLABLE}
33-
COMMAND ${PY_CMD} setup.py sdist
25+
COMMAND ${PY_CMD} -m build --wheel ${PY_DIRECTORY}
3426
WORKING_DIRECTORY ${PY_DIRECTORY}
3527
DEPENDS ${PYTHON_SOURCES} ${PYTHON_INCLUDES}
36-
COMMENT "Building sdist for ${PY_CMD}"
28+
COMMENT "Building ${PIP_INSTALLABLE} for ${PY_CMD}"
3729
)
3830
add_custom_target(bcc_py_${PY_CMD_ESCAPED} ALL DEPENDS ${PIP_INSTALLABLE})
3931

@@ -44,7 +36,8 @@ foreach(PY_CMD ${PYTHON_CMD})
4436
install(
4537
CODE "
4638
execute_process(
47-
COMMAND ${PY_CMD} setup.py install -f ${PYTHON_FLAGS} --prefix=${PYTHON_PREFIX} --record ${CMAKE_BINARY_DIR}/install_manifest_python_bcc.txt
48-
WORKING_DIRECTORY ${PY_DIRECTORY})"
39+
COMMAND ${PY_CMD} -m pip install --force-reinstall --prefix=${PYTHON_PREFIX} ${PIP_INSTALLABLE}
40+
WORKING_DIRECTORY ${PY_DIRECTORY})"
41+
COMMENT "Install ${PIP_INSTALLABLE} for ${PY_CMD}"
4942
COMPONENT python)
5043
endforeach()

0 commit comments

Comments
 (0)