Skip to content

Commit d0676ca

Browse files
fix: 简化 deploy.sh 中的 Python 验证逻辑
1 parent 377fee6 commit d0676ca

1 file changed

Lines changed: 6 additions & 23 deletions

File tree

deploy.sh

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -294,36 +294,19 @@ print_header "步骤 7/7: 验证 PyCANDYAlgo"
294294
print_step "测试导入..."
295295

296296
# 测试 PyCANDYAlgo 导入
297-
IMPORT_TEST=$(python3 << 'PYEOF'
298-
import sys
299-
try:
300-
import PyCANDYAlgo
301-
print(f"VERSION:{PyCANDYAlgo.__version__}")
302-
print("SUCCESS")
303-
except Exception as e:
304-
print(f"ERROR:{e}")
305-
sys.exit(1)
306-
PYEOF
307-
)
308-
309-
if echo "$IMPORT_TEST" | grep -q "SUCCESS"; then
310-
VERSION=$(echo "$IMPORT_TEST" | grep "VERSION:" | cut -d: -f2)
311-
print_success "PyCANDYAlgo 导入成功 (版本: $VERSION)"
297+
if python3 -c "import PyCANDYAlgo; print('VERSION:', PyCANDYAlgo.__version__)" 2>&1; then
298+
print_success "PyCANDYAlgo 导入成功"
312299
else
313300
print_error "PyCANDYAlgo 导入失败"
314-
echo "$IMPORT_TEST"
301+
# 显示详细错误
302+
python3 -c "import PyCANDYAlgo" 2>&1 || true
315303
exit 1
316304
fi
317305

318306
# 测试核心依赖
319307
print_step "测试核心依赖..."
320-
for pkg in numpy torch; do
321-
if python3 -c "import $pkg" 2>/dev/null; then
322-
print_success "$pkg 可用"
323-
else
324-
print_error "$pkg 不可用"
325-
fi
326-
done
308+
python3 -c "import numpy; print('numpy:', numpy.__version__)" || print_warning "numpy 不可用"
309+
python3 -c "import torch; print('torch:', torch.__version__)" || print_warning "torch 不可用"
327310

328311
# ============================================================================
329312
# 完成

0 commit comments

Comments
 (0)