chore: 迁移构建工具到 just
This commit is contained in:
parent
e1c2fc4db7
commit
44f93fb1e4
|
@ -7,6 +7,8 @@ kotonebot-ui/.vite
|
|||
dumps*/
|
||||
config.json
|
||||
reports/
|
||||
invoke.yml
|
||||
pyproject.toml
|
||||
##########################
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
|
|
18
README.md
18
README.md
|
@ -18,26 +18,18 @@ TODO
|
|||
## 开发
|
||||
> [!NOTE]
|
||||
> 建议使用 VSCode 进行开发。
|
||||
|
||||
首先安装 [just](https://github.com/casey/just#packages),然后:
|
||||
```bash
|
||||
git clone https://github.com/XcantloadX/KotonesAutoAssistant.git
|
||||
cd KotonesAutoAssistant
|
||||
```
|
||||
|
||||
### 后端
|
||||
```bash
|
||||
python -m venv venv
|
||||
source venv/bin/activate # Windows 系统: venv\Scripts\activate
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements.dev.txt
|
||||
python tools/make_resources.py
|
||||
just env
|
||||
```
|
||||
然后打开 VSCode 设置,搜索“SupportRestructured Text”并勾选。
|
||||
|
||||
### 前端
|
||||
### 打包
|
||||
```bash
|
||||
cd kotonebot-ui
|
||||
npm install
|
||||
npm run dev
|
||||
just package <版本号>
|
||||
```
|
||||
|
||||
### 截图
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
set dotenv-load
|
||||
set shell := ["powershell", "-c"]
|
||||
|
||||
shebang_pwsh := if os() == 'windows' {
|
||||
'powershell.exe'
|
||||
} else {
|
||||
'/usr/bin/env powershell'
|
||||
}
|
||||
shebang_python := if os() == 'windows' {
|
||||
'python.exe'
|
||||
} else {
|
||||
'/usr/bin/env python3'
|
||||
}
|
||||
venv := if os() == 'windows' {
|
||||
'.\.venv\Scripts\activate; '
|
||||
} else {
|
||||
'source ./.venv/bin/activate && '
|
||||
}
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Check and create virtual environment
|
||||
env:
|
||||
#!{{shebang_pwsh}}
|
||||
Write-Host "Creating virtual environment..."
|
||||
$IsWindows = $env:OS -match "Windows"
|
||||
|
||||
if (Test-Path ".venv") {
|
||||
Write-Host "Virtual environment already exists"
|
||||
} else {
|
||||
python -m venv .venv
|
||||
}
|
||||
|
||||
if ($IsWindows) {
|
||||
.\.venv\Scripts\pip install -r requirements.dev.txt
|
||||
} else {
|
||||
./.venv/bin/pip install -r requirements.dev.txt
|
||||
}
|
||||
|
||||
# Build the project using pyinstaller
|
||||
build: env
|
||||
{{venv}} pyinstaller -y kotonebot-gr.spec
|
||||
|
||||
# Generate pyproject.toml
|
||||
generate-pyproject-toml version:
|
||||
#!{{shebang_python}}
|
||||
from datetime import datetime
|
||||
|
||||
today = datetime.now()
|
||||
version = today.strftime("%Y.%m.%d")
|
||||
|
||||
with open("pyproject.template.toml", "r", encoding="utf-8") as f:
|
||||
template = f.read()
|
||||
|
||||
with open("pyproject.toml", "w", encoding="utf-8") as f:
|
||||
f.write(template.replace("<<<version>>>", version))
|
||||
|
||||
# Package KAA
|
||||
@package version: env
|
||||
Write-Host "Removing old build files..."
|
||||
if (Test-Path dist) { rm -r -fo dist }
|
||||
if (Test-Path build) { rm -r -fo build }
|
||||
Write-Host "Generating pyproject.toml..."
|
||||
just generate-pyproject-toml version
|
||||
Write-Host "Packaging KAA {{version}}..."
|
||||
@{{venv}} python -m build
|
||||
Write-Host "Removing pyproject.toml..."
|
||||
@rm -fo pyproject.toml
|
||||
|
||||
# Upload to PyPI
|
||||
publish version: (package version)
|
||||
# if (git diff-index --quiet HEAD) { } else { Write-Host "Error: Commit all changes before publishing"; exit 1 }
|
||||
@Write-Host "Uploading to PyPI..."
|
||||
twine upload dist/* -u __token__ -p $env:PYPI_TOKEN
|
||||
|
||||
# Upload to PyPI-Test
|
||||
publish-test version: (package version)
|
||||
@Write-Host "Uploading to PyPI-Test..."
|
||||
twine upload --repository testpypi dist/* -u __token__ -p $env:PYPI_TEST_TOKEN
|
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||
|
||||
[project]
|
||||
name = "kaa"
|
||||
version = "0.1.0.250123"
|
||||
version = "<<<version>>>"
|
||||
description = "Kotones Auto Assistant"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
|
@ -1,3 +1,4 @@
|
|||
-r requirements.txt
|
||||
jinja2==3.1.5
|
||||
pyinstaller==6.11.1
|
||||
twine==6.1.0
|
|
@ -1,12 +1,12 @@
|
|||
# 图像处理 & OCR
|
||||
# Image Processing & OCR
|
||||
opencv-python==4.10.0.84
|
||||
rapidocr_onnxruntime==1.4.3
|
||||
av==14.0.1
|
||||
scikit-image==0.25.0
|
||||
thefuzz==0.22.1
|
||||
# Adb 控制
|
||||
# Adb Control
|
||||
adbutils==2.8.0
|
||||
# 可视化调试页面
|
||||
# Visual Debugger
|
||||
fastapi==0.115.6
|
||||
uvicorn==0.34.0
|
||||
python-multipart==0.0.20
|
||||
|
@ -15,7 +15,7 @@ numpy==2.2.1
|
|||
psutil==6.1.1
|
||||
# GUI
|
||||
gradio==5.12.0
|
||||
# 配置读写
|
||||
# Configuration
|
||||
pydantic==2.10.4
|
||||
# 其他
|
||||
# Other
|
||||
typing-extensions==4.12.2
|
||||
|
|
41
tasks.py
41
tasks.py
|
@ -1,41 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from invoke import task, Context # type: ignore
|
||||
|
||||
@task
|
||||
def env(c: Context):
|
||||
"""检查并创建虚拟环境"""
|
||||
venv_path = Path(".venv")
|
||||
if not venv_path.exists():
|
||||
print("正在创建虚拟环境...")
|
||||
c.run("python -m venv .venv")
|
||||
|
||||
# 根据操作系统选择激活脚本
|
||||
if sys.platform == "win32":
|
||||
c.run(".venv\\Scripts\\pip install -r requirements.txt")
|
||||
else:
|
||||
c.run(".venv/bin/pip install -r requirements.txt")
|
||||
|
||||
print("虚拟环境创建完成并已安装依赖")
|
||||
else:
|
||||
print("虚拟环境已存在")
|
||||
|
||||
# 激活虚拟环境
|
||||
if sys.platform == "win32":
|
||||
c.run(".venv\\Scripts\\activate")
|
||||
else:
|
||||
c.run("source .venv/bin/activate")
|
||||
|
||||
@task(env)
|
||||
def build(c: Context):
|
||||
c.run("pyinstaller -y kotonebot-gr.spec")
|
||||
|
||||
@task(build)
|
||||
def package(c: Context):
|
||||
# copy files
|
||||
shutil.copytree("./res", "./dist/gr/res")
|
||||
# zip
|
||||
shutil.make_archive("./dist/gr", "zip", "./dist/gr")
|
|
@ -0,0 +1,2 @@
|
|||
PYPI_TOKEN=
|
||||
PYPI_TEST_TOKEN=
|
Loading…
Reference in New Issue