Skip to content

Commit 3c8c0f0

Browse files
authored
【Hackathon 9th No.109】[CppExtension] [XPU] Support build Custom OP in setuptools 80+ -part (#5106)
* [CppExtension] 添加现代Python打包方法兼容性支持 * [CppExtension] 移除构建脚本中的错误退出逻辑 * [CppExtension] 移除现代Python打包兼容性代码,仅保留传统打包方式 * [CppExtension] 恢复现代Python打包兼容性支持并优化目录检测逻辑
1 parent be9541a commit 3c8c0f0

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

custom_ops/xpu_ops/build.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,28 @@ SYSTEM_VERSION=`${python} -c "import platform; print(platform.system().lower())"
2626
PROCESSOR_VERSION=`${python} -c "import platform; print(platform.processor())"`
2727
WHEEL_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
2828

29+
# Add compatibility for modern python packaging methods
30+
WHEEL_MODERN_NAME="fastdeploy_ops"
31+
2932
${python} setup_ops.py install --install-lib ${OPS_TMP_DIR}
30-
mkdir -p ${OPS_TMP_DIR}/${WHEEL_NAME}/libs
31-
cp ${XVLLM_PATH}/xft_blocks/so/libxft_blocks.so ${OPS_TMP_DIR}/${WHEEL_NAME}/libs/
32-
cp ${XVLLM_PATH}/infer_ops/so/libapiinfer.so ${OPS_TMP_DIR}/${WHEEL_NAME}/libs/
33-
patchelf --set-rpath '$ORIGIN/libs' ${OPS_TMP_DIR}/${WHEEL_NAME}/fastdeploy_ops_pd_.so
33+
34+
# Handle directory compatibility between modern and legacy naming
35+
if [ -d "./${OPS_TMP_DIR}/${WHEEL_MODERN_NAME}" ]; then
36+
echo -e "${GREEN}[Info]${NONE} Ready to use ops from modern directory ${WHEEL_MODERN_NAME}"
37+
# Use modern directory name
38+
TARGET_DIR="${OPS_TMP_DIR}/${WHEEL_MODERN_NAME}"
39+
else
40+
# If modern directory doesn't exist, check for legacy directory
41+
if [ -d "./${OPS_TMP_DIR}/${WHEEL_NAME}" ]; then
42+
echo -e "${YELLOW}[Warning]${NONE} ${WHEEL_NAME} directory exists. This is a deprecated packaging and distribution method."
43+
else
44+
echo -e "${RED}[Error]${NONE} Neither modern nor legacy directory found in ${OPS_TMP_DIR}"
45+
fi
46+
# Use legacy directory name
47+
TARGET_DIR="${OPS_TMP_DIR}/${WHEEL_NAME}"
48+
fi
49+
50+
mkdir -p ${TARGET_DIR}/libs
51+
cp ${XVLLM_PATH}/xft_blocks/so/libxft_blocks.so ${TARGET_DIR}/libs/
52+
cp ${XVLLM_PATH}/infer_ops/so/libapiinfer.so ${TARGET_DIR}/libs/
53+
patchelf --set-rpath '$ORIGIN/libs' ${TARGET_DIR}/fastdeploy_ops_pd_.so

0 commit comments

Comments
 (0)