chore: 构建脚本
This commit is contained in:
parent
1d766818f1
commit
0519f46c7d
|
@ -1,2 +1,3 @@
|
|||
-r requirements.txt
|
||||
jinja2==3.1.5
|
||||
pyinstaller==6.11.1
|
||||
pyinstaller==6.11.1
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
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")
|
Loading…
Reference in New Issue