Unverified Commit 60ec0221 authored by hyrulelinks's avatar hyrulelinks Committed by GitHub
Browse files

Update README.md

更新MacOS、Python3.12环境下打包.app应用程序的步骤
parent f621cc61
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -55,14 +55,16 @@ $ python3 launch.py
![录屏2023-09-11 14 26 49](https://github.com/hyrulelinks/BallonsTranslator/assets/134026642/647c0fa0-ed37-49d6-bbf4-8a8697bc873e)

```
# 第1步:打开终端并确保当前终端窗口的Python大版本号是3.11,可以用下面的命令确认版本号
# 第1步:打开终端并确保当前终端窗口的Python大版本号是3.12,可以用下面的命令确认版本号
python3 -V
# 如果没有安装Python 3.12,可以通过Homebrew安装
brew install python@3.12 python-tk@3.12

# 第2步:克隆仓库并进入仓库工作目录
git clone -b dev https://github.com/dmMaze/BallonsTranslator.git
cd BallonsTranslator

# 第3步:创建和启用 Python 3.11 虚拟环境
# 第3步:创建和启用 Python 3.12 虚拟环境
python3 -m venv venv
source venv/bin/activate

@@ -70,13 +72,23 @@ source venv/bin/activate
pip3 install -r requirements.txt

# 第5步:源码运行程序,会自动下载 data 文件,每个文件在20-400MB左右,合计大约1.67GB,需要比较稳定的网络,如果下载报错,请重复运行下面的命令直至不再下载报错并启动程序
# 如果多次下载失败,也可以从 [MEGA](https://mega.nz/folder/gmhmACoD#dkVlZ2nphOkU5-2ACb5dKw) 或 [Google Drive](https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing) 下载 `libs` 和 `models` 并放入 data 文件夹
# 下载完毕后运行下面的命令,如果正常运行且未报错,则继续进入打包应用程序的步骤
python3 launch.py

# 第6步:运行下面的远程脚本开始构建 macOS 应用程序(仅限 Apple Silicon 芯片的 Mac 设备),中途 sudo 命令需要输入开机密码授予权限
cd ..
curl -L https://raw.githubusercontent.com/dmMaze/BallonsTranslator/dev/scripts/macos-build-script.sh | bash
```
# 第6步:下载https://github.com/dmMaze/PyPatchMatchInpaint/releases/download/v1.0/macos_arm64_patchmatch_libs.7z到项目根目录下的'.btrans_cache'隐藏文件夹
# 该步骤是为了防止打包好的应用程序首次启动时重新下载macos_arm64_patchmatch_libs.7z导致启动失败(大概率)
mkdir ./.btrans_cache2
curl -L https://github.com/dmMaze/PyPatchMatchInpaint/releases/download/v1.0/macos_arm64_patchmatch_libs.7z -o ./.btrans_cache/macos_arm64_patchmatch_libs.7z

# 第7步:下载微软雅黑字体并放到fonts文件夹下,该步骤为可选项,不影响打包,只影响字体报错信息

# 第8步:构建 macOS 应用程序中途 sudo 命令需要输入开机密码授予权限
# 安装打包工具pyinstaller
pip3 install pyinstaller
# 删除MacOS下特有的.DS_Store文件,这些文件可能导致打包失败(中概率)
sudo find ./ -name '.DS_Store' -delete
# 开始打包.app应用程序
sudo pyinstaller launch.spec

> 📌打包好的应用在`./data/BallonsTranslator/dist/BallonsTranslator.app`,将应用拖到 macOS 的应用程序文件夹即完成安装,开箱即用,不需要另外配置 Python 环境。