Files
bci_algo/nuitka_3in1_package.sh
2026-06-13 19:47:27 +08:00

54 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Git Bash 中文 UTF-8 兼容配置(通用版,无报错)
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
echo "========================"
echo "Nuitka 打包脚本 - 优化稳定版"
echo "适配PyTorch2.0.0 + CUDA11.7 + 脑电解码项目"
echo "========================"
# ===================== 自定义配置区 =====================
PY_FILE="runDecoder.py" # 主程序文件
OUT_DIR="dist_nuitka" # 输出文件夹
MODEL_DIR="online_Models" # 模型文件夹
# ========================================================
# 检查主文件是否存在
if [ ! -f "${PY_FILE}" ]; then
echo "错误:未找到主文件 ${PY_FILE},请检查路径!"
read -n 1 -s -r -p "按任意键退出"
exit 1
fi
echo "开始打包:${PY_FILE}"
echo "输出目录:${OUT_DIR}"
# Nuitka 核心打包命令(无错误、无冗余、全依赖)
python -m nuitka \
--standalone \
--msvc=latest \
--module-parameter=torch-disable-jit=yes \
--enable-plugin=no-qt \
--include-package=numpy \
--include-module=numpy.core._multiarray_umath \
--include-package=scipy \
--no-deployment-flag=self-execution \
--include-data-dir="${MODEL_DIR}=${MODEL_DIR}" \
--output-dir="${OUT_DIR}" \
--remove-output \
"${PY_FILE}"
# 打包结果判断
if [ $? -eq 0 ]; then
echo -e "\n========================"
echo "✅ 打包成功!"
echo "📦 产物路径:${OUT_DIR}/${PY_FILE%.py}.exe"
echo "========================"
else
echo -e "\n❌ 打包失败!"
fi
# Git Bash 兼容的暂停
read -n 1 -s -r -p "按任意键退出..."
echo