@@ -77,79 +77,81 @@ function copy_ops(){
7777 PY_VERSION=" py${PY_MAIN_VERSION} .${PY_SUB_VERSION} "
7878 SYSTEM_VERSION=` ${python} -c " import platform; print(platform.system().lower())" `
7979 PROCESSOR_VERSION=` ${python} -c " import platform; print(platform.processor())" `
80- WHEEL_NAME =" fastdeploy_ops-${OPS_VERSION} -${PY_VERSION} -${SYSTEM_VERSION} -${PROCESSOR_VERSION} .egg"
81- WHEEL_CPU_NAME =" fastdeploy_cpu_ops-${OPS_VERSION} -${PY_VERSION} -${SYSTEM_VERSION} -${PROCESSOR_VERSION} .egg"
80+ EGG_NAME =" fastdeploy_ops-${OPS_VERSION} -${PY_VERSION} -${SYSTEM_VERSION} -${PROCESSOR_VERSION} .egg"
81+ EGG_CPU_NAME =" fastdeploy_cpu_ops-${OPS_VERSION} -${PY_VERSION} -${SYSTEM_VERSION} -${PROCESSOR_VERSION} .egg"
8282
8383 # Add compatibility for modern python packaging methods
84- WHEEL_MODERN_NAME=" fastdeploy_ops"
85- WHEEL_MODERN_CPU_NAME=" fastdeploy_cpu_ops"
84+ LEGACY_PACKAGE_DIR=" ${OPS_TMP_DIR} /${EGG_NAME} "
85+ MODERN_PACKAGE_DIR=" ${OPS_TMP_DIR} /fastdeploy_ops"
86+ LEGACY_PACKAGE_DIR_CPU=" ${OPS_TMP_DIR} /${EGG_CPU_NAME} "
87+ MODERN_PACKAGE_DIR_CPU=" ${OPS_TMP_DIR} /fastdeploy_cpu_ops"
8688
87- # Handle GPU ops directories (WHEEL_MODERN_NAME and WHEEL_NAME)
88- if [ -d " ./ ${OPS_TMP_DIR} / ${WHEEL_MODERN_NAME }" ]; then
89+ # Handle GPU ops directory compatibility between modern and legacy naming
90+ if [ -d " ${MODERN_PACKAGE_DIR }" ]; then
8991 echo -e " ${GREEN} [Info]${NONE} Ready to copy ops from modern directory ${WHEEL_MODERN_NAME} to target directory"
90- # Set WHEEL_NAME to empty string to ignore the directory path
91- WHEEL_NAME=" "
92+ TMP_PACKAGE_DIR=" ${OPS_TMP_DIR} "
93+ # If modern directory doesn't exist, check for legacy directory, this branch should be removed in the future
94+ elif [ -d " ${LEGACY_PACKAGE_DIR} " ]; then
95+ echo -e " ${YELLOW} [Warning]${NONE} ${EGG_NAME} directory exists. This is a legacy packaging and distribution method."
96+ TMP_PACKAGE_DIR=" ${LEGACY_PACKAGE_DIR} "
9297 else
93- # If modern directory doesn't exist, check for deprecated directory
94- if [ -d " ./${OPS_TMP_DIR} /${WHEEL_NAME} " ]; then
95- echo -e " ${YELLOW} [Warning]${NONE} ${WHEEL_NAME} directory exists. This is a deprecated packaging and distribution method."
96- fi
98+ echo -e " ${RED} [Error]${NONE} Neither modern nor legacy directory for gpu ops found in ${OPS_TMP_DIR} "
9799 fi
98100
99- # Handle CPU ops directories (WHEEL_MODERN_CPU_NAME and WHEEL_CPU_NAME)
100- if [ -d " ./ ${OPS_TMP_DIR} / ${WHEEL_MODERN_CPU_NAME }" ]; then
101+ # Handle CPU ops directory compatibility between modern and legacy naming
102+ if [ -d " ${MODERN_PACKAGE_DIR_CPU }" ]; then
101103 echo -e " ${GREEN} [Info]${NONE} Ready to copy ops from modern directory ${WHEEL_MODERN_CPU_NAME} to target directory"
102- # Set WHEEL_CPU_NAME to empty string to ignore the directory path
103- WHEEL_CPU_NAME=" "
104+ TMP_PACKAGE_DIR_BASE=" ${OPS_TMP_DIR} "
105+ # If modern directory doesn't exist, check for legacy directory, this branch should be removed in the future
106+ elif [ -d " ${LEGACY_PACKAGE_DIR_CPU} " ]; then
107+ echo -e " ${YELLOW} [Warning]${NONE} ${EGG_CPU_NAME} directory exists. This is a legacy packaging and distribution method."
108+ TMP_PACKAGE_DIR_BASE=" ${LEGACY_PACKAGE_DIR_CPU} "
104109 else
105- # If modern directory doesn't exist, check for deprecated directory
106- if [ -d " ./${OPS_TMP_DIR} /${WHEEL_CPU_NAME} " ]; then
107- echo -e " ${YELLOW} [Warning]${NONE} ${WHEEL_CPU_NAME} directory exists. This is a deprecated packaging and distribution method."
108- fi
110+ echo -e " ${YELLOW} [Warning]${NONE} Neither modern nor legacy directory for cpu ops found in ${OPS_TMP_DIR} "
109111 fi
110112 is_rocm=` $python -c " import paddle; print(paddle.is_compiled_with_rocm())" `
111113 if [ " $is_rocm " = " True" ]; then
112114 DEVICE_TYPE=" rocm"
113- cp -r ./ ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/gpu
115+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/gpu
114116 echo -e " ROCM ops have been copy to fastdeploy"
115117 return
116118 fi
117119 is_cuda=` $python -c " import paddle; print(paddle.is_compiled_with_cuda())" `
118120 if [ " $is_cuda " = " True" ]; then
119121 DEVICE_TYPE=" gpu"
120- cp -r ./ ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/gpu
122+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/gpu
121123 echo -e " CUDA ops have been copy to fastdeploy"
122124 return
123125 fi
124126
125127 is_xpu=` $python -c " import paddle; print(paddle.is_compiled_with_xpu())" `
126128 if [ " $is_xpu " = " True" ]; then
127129 DEVICE_TYPE=" xpu"
128- cp -r ./ ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/xpu
130+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/xpu
129131 echo -e " xpu ops have been copy to fastdeploy"
130132 return
131133 fi
132134
133135 is_npu=` $python -c " import paddle; print(paddle.is_compiled_with_custom_device('npu'))" `
134136 if [ " $is_npu " = " True" ]; then
135137 DEVICE_TYPE=" npu"
136- cp -r ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/npu
138+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/npu
137139 echo -e " npu ops have been copy to fastdeploy"
138140 return
139141 fi
140142
141143 if_corex=` $python -c " import paddle; print(paddle.is_compiled_with_custom_device(\" iluvatar_gpu\" ))" `
142144 if [ " $if_corex " = " True" ]; then
143145 DEVICE_TYPE=" iluvatar-gpu"
144- cp -r ./ ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/iluvatar
146+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/iluvatar
145147 echo -e " Iluvatar ops have been copy to fastdeploy"
146148 return
147149 fi
148150
149151 is_gcu=` $python -c " import paddle; print(paddle.is_compiled_with_custom_device('gcu'))" `
150152 if [ " $is_gcu " = " True" ]; then
151153 DEVICE_TYPE=" gcu"
152- cp -r ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/gcu
154+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/gcu
153155 echo -e " gcu ops have been copy to fastdeploy"
154156 return
155157 fi
@@ -158,8 +160,8 @@ function copy_ops(){
158160 if [ " $is_maca " = " True" ]; then
159161 DEVICE_TYPE=" metax_gpu"
160162 mkdir -p ../fastdeploy/model_executor/ops/base
161- cp -r ./ ${OPS_TMP_DIR_BASE} /${WHEEL_BASE_NAME} /* ../fastdeploy/model_executor/ops/base
162- cp -r ./ ${OPS_TMP_DIR} / ${WHEEL_NAME } /* ../fastdeploy/model_executor/ops/gpu
163+ cp -r ${OPS_TMP_DIR_BASE} /${WHEEL_BASE_NAME} /* ../fastdeploy/model_executor/ops/base
164+ cp -r ${TMP_PACKAGE_DIR } /* ../fastdeploy/model_executor/ops/gpu
163165 echo -e " MACA ops have been copy to fastdeploy"
164166 return
165167 fi
@@ -249,8 +251,14 @@ function extract_ops_from_precompiled_wheel() {
249251 echo -e " ${BLUE} [precompiled]${NONE} Copying GPU precompiled contents..."
250252 mkdir -p " $DST_DIR "
251253 cp -r " $SRC_DIR /deep_gemm" " $DST_DIR /" 2> /dev/null || true
252- cp -r " $SRC_DIR /fastdeploy_ops.py" " $DST_DIR /" 2> /dev/null || true
253- cp -f " $SRC_DIR /" fastdeploy_ops_* .so " $DST_DIR /" 2> /dev/null || true
254+ # Check for modern Python packaging approach (fastdeploy_ops directory)
255+ # If exists, copy the entire directory; otherwise, fall back to legacy method (individual files)
256+ if [ -d " $SRC_DIR /fastdeploy_ops" ]; then
257+ cp -r " $SRC_DIR /fastdeploy_ops" " $DST_DIR /" 2> /dev/null || true
258+ else
259+ cp -r " $SRC_DIR /fastdeploy_ops.py" " $DST_DIR /" 2> /dev/null || true
260+ cp -f " $SRC_DIR /" fastdeploy_ops_* .so " $DST_DIR /" 2> /dev/null || true
261+ fi
254262 cp -f " $SRC_DIR /version.txt" " $DST_DIR /" 2> /dev/null || true
255263
256264 echo -e " ${GREEN} [SUCCESS]${NONE} Installed FastDeploy using precompiled wheel."
0 commit comments