- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
50 lines
1.3 KiB
Bash
Executable File
50 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# EPUB 双语翻译程序安装脚本
|
|
|
|
echo "正在安装 EPUB 双语翻译程序..."
|
|
|
|
# 检查 Python 版本
|
|
python_version=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2)
|
|
required_version="3.9"
|
|
|
|
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
|
|
echo "错误: 需要 Python 3.9 或更高版本,当前版本: $python_version"
|
|
exit 1
|
|
fi
|
|
|
|
# 检查 uv 是否安装
|
|
if ! command -v uv &> /dev/null; then
|
|
echo "正在安装 uv..."
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
source $HOME/.cargo/env
|
|
fi
|
|
|
|
# 创建虚拟环境
|
|
echo "正在创建虚拟环境..."
|
|
uv venv
|
|
|
|
# 激活虚拟环境
|
|
source .venv/bin/activate
|
|
|
|
# 安装依赖
|
|
echo "正在安装依赖..."
|
|
uv pip install -r requirements.txt
|
|
|
|
# 创建必要的目录
|
|
mkdir -p output logs
|
|
|
|
# 复制配置文件示例
|
|
if [ ! -f ".env" ]; then
|
|
cp .env.example .env
|
|
echo "已创建 .env 文件,请编辑并添加你的 OpenRouter API Key"
|
|
fi
|
|
|
|
echo "安装完成!"
|
|
echo ""
|
|
echo "下一步:"
|
|
echo "1. 编辑 .env 文件,添加你的 OpenRouter API Key"
|
|
echo "2. 激活虚拟环境: source .venv/bin/activate"
|
|
echo "3. 运行测试: python main.py your_book.epub --test"
|
|
echo ""
|
|
echo "使用帮助: python main.py --help" |