diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index 65b7618..0ffc484 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -11,7 +11,7 @@ from pathlib import Path from Difficult_Rocket.api.types import Options, Version sdk_version = Version("0.8.5.1") # SDK 版本 -build_version = Version("2.1.1.0") # 编译文件版本(与游戏本体无关) +build_version = Version("2.1.2.0") # 编译文件版本(与游戏本体无关) Api_version = Version("0.1.1.0") # API 版本 __version__ = sdk_version diff --git a/docs/src/change_log/build_file.md b/docs/src/change_log/build_file.md index 9731167..985a561 100644 --- a/docs/src/change_log/build_file.md +++ b/docs/src/change_log/build_file.md @@ -2,7 +2,18 @@ # DR 构建 更新日志 - 最新构建版本号 - - build_version: 2.1.1.0 + - build_version: 2.1.2.0 + +## 20230708 build 2.1.2.0 + +### 修改 + +- 同步了 `lib-not-dr` 的修改 + - `NuitkaCompiler` + - 添加了 `run_after_build` 选项 + - `--run` + - 添加了 `compat_nuitka_version` 选项 + - 目前是 `1.7.1` ## 20230630 build 2.1.1.0 diff --git a/libs/utils/nuitka.py b/libs/utils/nuitka.py index e721c8b..37b6083 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -6,11 +6,12 @@ # 用于使用 nuitka 构建 DR import platform +import warnings import traceback from pathlib import Path from typing import List, Tuple, Optional, Any -from Difficult_Rocket.api.types import Options, Version +from Difficult_Rocket.api.types import Options, Version, VersionRequirement def _add_cmd(cmd: List[str], string: Optional[Any]) -> List[str]: @@ -20,12 +21,18 @@ def _add_cmd(cmd: List[str], string: Optional[Any]) -> List[str]: class CompilerHelper(Options): + """ + 用于帮助生成 nuitka 构建脚本的类 + Use to help generate nuitka build script + + """ name = 'Nuitka Compiler Helper' output_path: Path = Path("./build/nuitka") src_file: Path = Path('DR.py') python_cmd: str = 'python' + compat_nuitka_version: VersionRequirement = VersionRequirement("~1.7.1") # STATIC VERSION # 以下为 nuitka 的参数 use_lto: bool = False # --lto=yes (no is faster) @@ -42,6 +49,7 @@ class CompilerHelper(Options): xml_path: Path = Path('build/compile_data.xml') download_confirm: bool = True # --assume-yes-for-download + run_after_build: bool = False # --run company_name: str = 'tool-shenjack-workshop' product_name: str = 'Difficult-Rocket' @@ -65,6 +73,12 @@ class CompilerHelper(Options): disable_plugin: List[str] = [] # --disable-plugin=xxx,xxx def init(self, **kwargs) -> None: + if (compat_version := kwargs.get('compat_nuitka_version')) is not None: + if not self.compat_nuitka_version.accept(compat_version): + warnings.warn( + f"Nuitka version may not compat with {compat_version}\n" + "requirement: {self.compat_nuitka_version}" + ) # 非 windows 平台不使用 msvc if platform.system() != 'Windows': self.use_msvc = False @@ -87,11 +101,32 @@ class CompilerHelper(Options): return self.as_markdown() def as_markdown(self, longest: Optional[int] = None) -> str: + """ + 输出编译器帮助信息 + Output compiler help information + + Args: + longest (Optional[int], optional): + 输出信息的最大长度限制 The maximum length of output information. + Defaults to None. + + Returns: + str: 以 markdown 格式输出的编译器帮助信息 + Compile helper information in markdown format + """ front = super().as_markdown(longest) gen_cmd = self.gen_subprocess_cmd() return f"{front}\n\n```bash\n{' '.join(gen_cmd)}\n```" def gen_subprocess_cmd(self) -> List[str]: + """生成 nuitka 构建脚本 + Generate nuitka build script + + Returns: + List[str]: + 生成的 nuitka 构建脚本 + Generated nuitka build script + """ cmd_list = [self.python_cmd, '-m', 'nuitka'] # macos 和 非 macos icon 参数不同 if platform.system() == 'Darwin': @@ -112,6 +147,7 @@ class CompilerHelper(Options): _add_cmd(cmd_list, '--show-progress' if self.show_progress else None) _add_cmd(cmd_list, '--show-memory' if self.show_memory else None) _add_cmd(cmd_list, '--assume-yes-for-download' if self.download_confirm else None) + _add_cmd(cmd_list, '--run' if self.run_after_build else None) _add_cmd(cmd_list, '--enable-console' if self.enable_console else '--disable-console') _add_cmd(cmd_list, f'--xml={self.xml_path.absolute()}' if self.save_xml else None) @@ -133,5 +169,5 @@ class CompilerHelper(Options): if self.include_packages: cmd_list += [f"--include-package={package}" for package in self.include_packages] - cmd_list.append(f"{self.src_file}") + cmd_list.append(f"--main={self.src_file}") return cmd_list diff --git a/mods/dr_game/Difficult_Rocket_rs/src/pyproject.toml b/mods/dr_game/Difficult_Rocket_rs/src/pyproject.toml index 91bc757..4e9bd60 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/pyproject.toml +++ b/mods/dr_game/Difficult_Rocket_rs/src/pyproject.toml @@ -15,4 +15,5 @@ classifiers = [ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] \ No newline at end of file