从源码运行 arknights-mower

本文介绍如何从源码运行 arknights-mower。

Python 3.12

从 Python 官网下载 3.12.4 版本并安装:

https://www.python.org/ftp/python/3.12.4/python-3.12.4-amd64.exe

Ubuntu 24.04 自带 Python 3.12.3,直接安装即可:

1
sudo apt install python3-venv python3-tk python3-dev

对于其它版本的 Ubuntu,可通过 deadsnakes ppa 安装:

1
2
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.12 python3.12-venv python3.12-tk python3.12-dev

使用 Homebrew 安装 Python 3.12:

1
brew install python@3.12 python-tk@3.12

Node.js 18

从 Node.js 官网下载 v18.20.3 的 msi 安装:

https://nodejs.org/dist/v18.20.3/node-v18.20.3-x64.msi

Ubuntu 24.04 自带 Node.js 18.19.1,直接安装即可:

1
sudo apt install nodejs npm

对于其它版本的 Ubuntu,可添加 NodeSource 软件源安装:

1
2
3
4
sudo apt install curl
curl -fsSL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs

使用 Homebrew 安装:

1
brew install node@18

其它依赖

1
sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config gir1.2-webkit2-4.1 gir1.2-appindicator3-0.1 libzbar0 adb git
1
brew install zbar

下载代码

1
2
git clone https://github.com/ArkMowers/arknights-mower --branch dev_shawn
cd arknights-mower

构建前端

1
2
3
4
5
cd ui
npm ci
npm run build
xcopy /s /e /h /y /i dist ..\dist
cd ..
1
2
3
4
cd ui
npm ci
npm run build
cd ..

将生成的 ui/dist 软链接至 arknights-mower 下:

1
ln -s ui/dist .
1
2
3
4
cd ui
npm ci
npm run build
cd ..

将生成的 ui/dist 软链接至 arknights-mower 下:

1
ln -s ui/dist .

Python 依赖

建立并激活虚拟环境,安装依赖。

如果在安装 Python 时未将其加入 PATH,则需手动指定完整路径。默认安装路径为 %LocalAppData%\Programs\Python\Python312

1
2
3
%LocalAppData%\Programs\Python\Python312\python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
1
2
3
4
python3.12 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install pycairo PyGObject
1
2
3
$(brew --prefix)/opt/python@3.12/libexec/bin/python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

运行

1
python webview_ui.py
1
./webview_ui.py
1
./webview_ui.py