Update dev script build

This commit is contained in:
muzing 2023-12-29 16:13:12 +08:00
parent 9f0a0bd1cd
commit 9b0555bdac

View File

@ -1,5 +1,4 @@
""" """用于构建项目的脚本
用于构建项目的脚本
""" """
import subprocess import subprocess
@ -21,10 +20,11 @@ from dev_scripts.path_constants import (
def process_md_images(md_file_list: list[Path]) -> None: def process_md_images(md_file_list: list[Path]) -> None:
""" """处理 Markdown 文档中的图片链接
处理 Markdown 文档中的图片链接 \n
在构建前替换为 GitHub 图床链接在构建后替换回本地目录中的路径 \n 在构建前替换为 GitHub 图床链接在构建后替换回本地目录中的路径
:return: 处理方向0-处置至本地路径1-处理至GitHub路径
:param md_file_list: Markdown 文件列表
""" """
md_uri = "docs/source/images/" md_uri = "docs/source/images/"
@ -47,8 +47,8 @@ def process_md_images(md_file_list: list[Path]) -> None:
def compile_resources() -> int: def compile_resources() -> int:
""" """调用 RCC 工具编译静态资源
调用 RCC 工具编译静态资源 \n
:return: rcc 进程返回码 :return: rcc 进程返回码
""" """
@ -57,17 +57,22 @@ def compile_resources() -> int:
cmd = [ cmd = [
"pyside6-rcc", "pyside6-rcc",
"-o", "-o",
str(compiled_file_path.resolve()), str(compiled_file_path.absolute()),
str(qrc_file_path.resolve()), str(qrc_file_path.absolute()),
] ]
result = subprocess.run(cmd) try:
print(f"已完成静态资源文件编译RCC返回码{result.returncode}") result = subprocess.run(cmd)
return result.returncode except subprocess.SubprocessError as e:
print(f"RCC编译进程错误{e}")
raise e
else:
print(f"已完成静态资源文件编译RCC返回码{result.returncode}")
return result.returncode
def export_requirements() -> int: def export_requirements() -> int:
""" """将项目依赖项导出至 requirements.txt 中
将项目依赖项导出至 requirements.txt
:return: poetry export 命令返回值 :return: poetry export 命令返回值
""" """
@ -79,15 +84,19 @@ def export_requirements() -> int:
PROJECT_ROOT / "requirements.txt", PROJECT_ROOT / "requirements.txt",
"--format=requirements.txt", "--format=requirements.txt",
] ]
result = subprocess.run(poetry_export_cmd)
print(f"已将当前项目依赖导出至 requirements.txtpoetry export 返回码:{result.returncode}") try:
return result.returncode result = subprocess.run(poetry_export_cmd)
except subprocess.SubprocessError as e:
print(f"poetry export 进程错误:{e}")
raise e
else:
print(f"已将当前项目依赖导出至 requirements.txtpoetry export 返回码:{result.returncode}")
return result.returncode
def build_py2exe_gui() -> None: def build_py2exe_gui() -> None:
""" """构建项目的总函数"""
构建项目的总函数 \n
"""
if check_version_num() + check_license_statement() == 0: if check_version_num() + check_license_statement() == 0:
# 准备工作 # 准备工作