From 1c5adf8f914f7f073f4a0a5b4b98d25d7aacc7cd Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:10:08 +0800 Subject: [PATCH 1/5] Update launch.spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加隐藏导入和人工导入的模块 --- launch.spec | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/launch.spec b/launch.spec index 9a7913ea..a5e8026a 100644 --- a/launch.spec +++ b/launch.spec @@ -8,7 +8,7 @@ import subprocess commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() # 构造带提交哈希值的版本号 -version = "1.3.35.dev." + commit_hash +version = "1.4.0.dev." + commit_hash block_cipher = None @@ -20,6 +20,7 @@ a = Analysis([ ], binaries=[], datas=[ + ('.btrans_cache', './.btrans_cache'), ('config', './config'), ('data', './data'), ('doc', './doc'), @@ -30,8 +31,10 @@ a = Analysis([ ('translate', './translate'), ('ui', './ui'), ('utils', './utils'), - ('venv/lib/python3.11/site-packages/spacy_pkuseg', './spacy_pkuseg'), - ('venv/lib/python3.11/site-packages/torchvision', './torchvision'), + ('venv/lib/python3.12/site-packages/spacy_pkuseg', './spacy_pkuseg'), + ('venv/lib/python3.12/site-packages/torchvision', './torchvision'), + ('venv/lib/python3.12/site-packages/translators', './translators'), + ('venv/lib/python3.12/site-packages/cryptography', './cryptography'), ], hiddenimports=[ 'PyQt6', @@ -62,6 +65,8 @@ a = Analysis([ 'httpx', 'langdetect', 'srsly', + 'execjs', + 'pathos', ], hookspath=[], hooksconfig={}, From f621cc610ef2d40a707f0951ae95af81f8a41f9d Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:12:55 +0800 Subject: [PATCH 2/5] Update requirements.txt Use latest urllib3 on macOS to fix urllib3.package.six.move module not found error --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 900cad80..e5111bd5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,8 @@ PyQt6-Qt6>=6.6.2 PyQt6>=6.6.1 numpy -urllib3==1.25.11 # https://github.com/psf/requests/issues/5740 +urllib3==1.25.11; sys_platform == 'win32' # https://github.com/psf/requests/issues/5740 +urllib3; sys_platform == 'darwin' # fix urllib3.package.six.move module not found error jaconv torch torchvision From 60ec022195a10a382b2ae37bc3a7f05c6f337ce9 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:30:29 +0800 Subject: [PATCH 3/5] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新MacOS、Python3.12环境下打包.app应用程序的步骤 --- README.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a9d88a91..65775c8a 100644 --- a/README.md +++ b/README.md @@ -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 环境。 From 0c915974356822e46491f8d33d8e86a72cedad58 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:32:20 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65775c8a..da5a3e36 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ pip3 install -r requirements.txt # 下载完毕后运行下面的命令,如果正常运行且未报错,则继续进入打包应用程序的步骤 python3 launch.py -# 第6步:下载https://github.com/dmMaze/PyPatchMatchInpaint/releases/download/v1.0/macos_arm64_patchmatch_libs.7z到项目根目录下的'.btrans_cache'隐藏文件夹 +# 第6步:下载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 From c45031255640bb9472898466c2416d5d2be5e576 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:33:47 +0800 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da5a3e36..374f2324 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ pip3 install pyinstaller sudo find ./ -name '.DS_Store' -delete # 开始打包.app应用程序 sudo pyinstaller launch.spec - +``` > 📌打包好的应用在`./data/BallonsTranslator/dist/BallonsTranslator.app`,将应用拖到 macOS 的应用程序文件夹即完成安装,开箱即用,不需要另外配置 Python 环境。 ## 一键翻译