From c35e540c18242670c5ef8fb2ad7567ea500a3b07 Mon Sep 17 00:00:00 2001 From: megemini Date: Mon, 17 Nov 2025 11:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Hackathon=209th=20No.109=E3=80=91[CppE?= =?UTF-8?q?xtension]=20Support=20build=20Custom=20OP=20in=20setuptools=208?= =?UTF-8?q?0+=20(#4977)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加对现代Python打包方法的兼容性支持 * [CppExtension] 优化构建脚本逻辑并更新.gitignore --- .gitignore | 1 + build.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/.gitignore b/.gitignore index 7aa0aa399..134c68d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -136,6 +136,7 @@ kernel_meta* fastdeploy_ops.py version.txt EGG-INFO/ +**/fastdeploy_ops/__init__.py # fp8 generated codes autogen/ diff --git a/build.sh b/build.sh index 7c9e0ab63..e63dd9043 100644 --- a/build.sh +++ b/build.sh @@ -79,6 +79,34 @@ function copy_ops(){ PROCESSOR_VERSION=`${python} -c "import platform; print(platform.processor())"` WHEEL_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg" WHEEL_CPU_NAME="fastdeploy_cpu_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg" + + # Add compatibility for modern python packaging methods + WHEEL_MODERN_NAME="fastdeploy_ops" + WHEEL_MODERN_CPU_NAME="fastdeploy_cpu_ops" + + # Handle GPU ops directories (WHEEL_MODERN_NAME and WHEEL_NAME) + if [ -d "./${OPS_TMP_DIR}/${WHEEL_MODERN_NAME}" ]; then + echo -e "${GREEN}[Info]${NONE} Ready to copy ops from modern directory ${WHEEL_MODERN_NAME} to target directory" + # Set WHEEL_NAME to empty string to ignore the directory path + WHEEL_NAME="" + else + # If modern directory doesn't exist, check for deprecated directory + if [ -d "./${OPS_TMP_DIR}/${WHEEL_NAME}" ]; then + echo -e "${YELLOW}[Warning]${NONE} ${WHEEL_NAME} directory exists. This is a deprecated packaging and distribution method." + fi + fi + + # Handle CPU ops directories (WHEEL_MODERN_CPU_NAME and WHEEL_CPU_NAME) + if [ -d "./${OPS_TMP_DIR}/${WHEEL_MODERN_CPU_NAME}" ]; then + echo -e "${GREEN}[Info]${NONE} Ready to copy ops from modern directory ${WHEEL_MODERN_CPU_NAME} to target directory" + # Set WHEEL_CPU_NAME to empty string to ignore the directory path + WHEEL_CPU_NAME="" + else + # If modern directory doesn't exist, check for deprecated directory + if [ -d "./${OPS_TMP_DIR}/${WHEEL_CPU_NAME}" ]; then + echo -e "${YELLOW}[Warning]${NONE} ${WHEEL_CPU_NAME} directory exists. This is a deprecated packaging and distribution method." + fi + fi is_rocm=`$python -c "import paddle; print(paddle.is_compiled_with_rocm())"` if [ "$is_rocm" = "True" ]; then DEVICE_TYPE="rocm"