From aa8c7b923996fc92952c08a9a4f903aa30ba4352 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 15:10:15 +0800 Subject: [PATCH 01/29] make build script using python --- biggit.ps1 | 20 -------------------- biggit.sh | 27 --------------------------- nuitka_build.py | 13 +++++++++++++ py_compile.ps1 | 6 ------ 4 files changed, 13 insertions(+), 53 deletions(-) delete mode 100644 biggit.ps1 delete mode 100644 biggit.sh create mode 100644 nuitka_build.py delete mode 100644 py_compile.ps1 diff --git a/biggit.ps1 b/biggit.ps1 deleted file mode 100644 index 70c643d..0000000 --- a/biggit.ps1 +++ /dev/null @@ -1,20 +0,0 @@ - -$objects = git verify-pack -v .git/objects/pack/pack-aba4bfc55979194c86dbd466c86e57d8199ae7ad.idx | Select-String -Pattern 'chain' -NotMatch | ForEach-Object {$_.Line} | Sort-Object -Property @{Expression={$_.Split(" ")[2]}; Ascending=$false} | Select-Object -First 50 - -Write-Output "All sizes are in kB. The pack column is the size of the object, compressed, inside the pack file." - -$output = "size,pack,SHA,location" -foreach ($y in $objects) { - # extract the size in bytes - $size = [int]($y.Split(" ")[4]/1024) - # extract the compressed size in bytes - $compressedSize = [int]($y.Split(" ")[5]/1024) - # extract the SHA - $sha = $y.Split(" ")[0] - # find the objects location in the repository tree - $other = git rev-list --all --objects | Select-String $sha - $output += "`n${size},${compressedSize},${other}" -} - -Write-Output $output | ConvertFrom-Csv -Delimiter "," | Format-Table -Pause diff --git a/biggit.sh b/biggit.sh deleted file mode 100644 index 3369e44..0000000 --- a/biggit.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -#set -x -IFS=$'\n'; - -# 默认值是 10个 可以一次性展示更多 就修改第15行代码 | head -n 30 或者更多 -objects=`git verify-pack -v .git/objects/pack/pack-aba4bfc55979194c86dbd466c86e57d8199ae7ad.idx | grep -v chain | sort -k3nr | head -n 50` - -echo "All sizes are in kB. The pack column is the size of the object, compressed, inside the pack file." - -output="size,pack,SHA,location" -for y in $objects -do - # extract the size in bytes - size=$((`echo $y | cut -f 5 -d ' '`/1024)) - # extract the compressed size in bytes - compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024)) - # extract the SHA - sha=`echo $y | cut -f 1 -d ' '` - # find the objects location in the repository tree - other=`git rev-list --all --objects | grep $sha` - #lineBreak=`echo -e "\n"` - output="${output}\n${size},${compressedSize},${other}" -done - -echo -e $output | column -t -s ', ' - -pause diff --git a/nuitka_build.py b/nuitka_build.py new file mode 100644 index 0000000..28b075d --- /dev/null +++ b/nuitka_build.py @@ -0,0 +1,13 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- + +import subprocess +from libs.utils import nuitka + +if __name__ == '__main__': + compiler = nuitka.Status() + + diff --git a/py_compile.ps1 b/py_compile.ps1 deleted file mode 100644 index 90472b6..0000000 --- a/py_compile.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -allPython.ps1 -m compileall 'libs\' -allPython.ps1 -m compileall 'Difficult_Rocket\' -allPython.ps1 -O -m compileall 'libs\' -allPython.ps1 -O -m compileall 'Difficult_Rocket\' -allPython.ps1 -OO -m compileall 'libs\' -allPython.ps1 -OO -m compileall 'Difficult_Rocket\' \ No newline at end of file -- 2.45.2 From 0ed52992785da06769c12c76b07ce414cf9b4c19 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 15:40:30 +0800 Subject: [PATCH 02/29] impl build script --- libs/utils/nuitka.py | 28 ++++++++++++++++++++++++---- nuitka_build.py | 3 +++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/libs/utils/nuitka.py b/libs/utils/nuitka.py index f72ad91..7b327a5 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -16,7 +16,7 @@ from Difficult_Rocket.api.types import Options, Version class Status(Options): name = 'Nuitka Build Status' - output_path: Path = Path("./build/nuitka") + output_path: Path = Path("./build/nuitka-win") src_file: Path = Path('DR.py') # 以下为 nuitka 的参数 @@ -25,13 +25,20 @@ class Status(Options): use_msvc: bool = True # --msvc=latest use_mingw: bool = False # --mingw64 standalone: bool = True # --standalone + + show_progress: bool = True # --show-progress + show_memory: bool = False # --show-memory + company_name: str = 'tool-shenjack-workshop' product_name: str = 'Difficult-Rocket' product_version: Version file_version: Version + icon_path: Path = Path('textures/icon.png') + follow_import: List[str] = ['pyglet', 'Difficult_Rocket.api'] - no_follow_import: List[str] = ['objprint', 'pillow', 'PIL', 'cffi', 'pydoc'] + no_follow_import: List[str] = ['objprint', 'pillow', 'PIL', 'cffi', 'pydoc', 'numpy'] + include_data_dir: List[Tuple[Path, Path]] = [(Path('./libs/fonts'), Path('./libs/fonts')), (Path('./textures'), Path('./textures')), (Path('./configs'), Path('./configs'))] @@ -83,14 +90,27 @@ class Status(Options): cmd_list.append('--msvc=latest') if self.standalone: cmd_list.append('--standalone') + if self.show_progress: + cmd_list.append('--show-progress') + if self.show_memory: + cmd_list.append('--show-memory') + + cmd_list.append(f"--output-dir={self.output_path.absolute()}") cmd_list.append(f"--company-name={self.company_name}") cmd_list.append(f"--product-name={self.product_name}") cmd_list.append(f"--product-version={self.product_version}") cmd_list.append(f"--file-version={self.file_version}") - cmd_list += icon_cmd - cmd_list += [f"--include-data-file={src}={dst}" for src, dst in self.include_data_dir] + + cmd_list.append(icon_cmd) + + cmd_list += [f"--include-data-dir={src}={dst}" for src, dst in self.include_data_dir] cmd_list += [f"--include-package={package}" for package in self.include_packages] + + cmd_list.append(f"--follow-import-to={','.join(self.follow_import)}") + cmd_list.append(f"--nofollow-import-to={','.join(self.no_follow_import)}") + + cmd_list.append(f"{self.src_file}") return cmd_list diff --git a/nuitka_build.py b/nuitka_build.py index 28b075d..1fa56a9 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -10,4 +10,7 @@ from libs.utils import nuitka if __name__ == '__main__': compiler = nuitka.Status() + print(compiler) + + print(compiler.gen_subprocess_cmd()) -- 2.45.2 From 0f053d91335f7001a9630b704e925a4035979357 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 16:17:04 +0800 Subject: [PATCH 03/29] many commit! --- Difficult_Rocket/__init__.py | 4 +-- README.md | 2 +- docs/README-en.md | 2 +- docs/src/change_log/build_file.md | 12 ++++++++ docs/src/change_log/dr_sdk.md | 4 +++ nuitka-mac.ps1 | 48 ------------------------------ nuitka-win.ps1 | 49 ------------------------------- pyproject.toml | 2 +- 8 files changed, 21 insertions(+), 102 deletions(-) create mode 100644 docs/src/change_log/build_file.md delete mode 100644 nuitka-mac.ps1 delete mode 100644 nuitka-win.ps1 diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index e75e021..2995463 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -16,8 +16,8 @@ from Difficult_Rocket.api.types import Options from libs.MCDR.version import Version -game_version = Version("0.8.0.0") # 游戏版本 -build_version = Version("1.2.1.0") # 编译文件版本(与游戏本体无关) +game_version = Version("0.8.1.0") # 游戏版本 +build_version = Version("1.3.0.0") # 编译文件版本(与游戏本体无关) Api_version = Version("0.1.1.0") # API 版本 __version__ = game_version diff --git a/README.md b/README.md index 5b79adc..a69db7a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ [关于版本号的说明](./docs/src/version.md) [![Generic badge](https://img.shields.io/badge/Release-0.8.0.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) -[![Generic badge](https://img.shields.io/badge/Pre_Release-0.8.0.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Pre_Release-0.8.0.1-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) [![Generic badge](https://img.shields.io/badge/Devloping-0.8.1-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) [![language badge](https://stats.deeptrain.net/repo/shenjackyuanjie/Difficult-Rocket?theme=dark)](https://stats.deeptrain.net/repo/shenjackyuanjie/Difficult-Rocket?theme=dark) diff --git a/docs/README-en.md b/docs/README-en.md index 9f83299..d85a0fa 100644 --- a/docs/README-en.md +++ b/docs/README-en.md @@ -20,7 +20,7 @@ [About Versions](src/version.md) [![Generic badge](https://img.shields.io/badge/Release-0.8.0.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) -[![Generic badge](https://img.shields.io/badge/Pre_Release-0.8.0.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Pre_Release-0.8.0.1-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) [![Generic badge](https://img.shields.io/badge/Devloping-0.8.1-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) [![language badge](https://stats.deeptrain.net/repo/shenjackyuanjie/Difficult-Rocket?theme=dark)](https://stats.deeptrain.net/repo/shenjackyuanjie/Difficult-Rocket?theme=dark) diff --git a/docs/src/change_log/build_file.md b/docs/src/change_log/build_file.md new file mode 100644 index 0000000..a324045 --- /dev/null +++ b/docs/src/change_log/build_file.md @@ -0,0 +1,12 @@ + +# DR 构建 更新日志 + +- 最新构建版本号 + - build_version: 1.3.0.0 + + + +## 20230609 build 1.3.0.0 + +- 修改 + - 向 `bifollow-import-to` 添加 `pydoc` diff --git a/docs/src/change_log/dr_sdk.md b/docs/src/change_log/dr_sdk.md index 40f9527..f7d9ea9 100644 --- a/docs/src/change_log/dr_sdk.md +++ b/docs/src/change_log/dr_sdk.md @@ -15,3 +15,7 @@ - `api.types` - 添加 `Version` (`libs.MCDR.version.Version`) + +### 修复 Bug + +- 自带的 `console` 类在 `get_command` 时 没有检查是否为空 diff --git a/nuitka-mac.ps1 b/nuitka-mac.ps1 deleted file mode 100644 index 7ae1b92..0000000 --- a/nuitka-mac.ps1 +++ /dev/null @@ -1,48 +0,0 @@ -$start_time = Get-Uptime -Write-Output $start_time - -python3 .github/workflows/get_info.py -env - -if (-Not (Test-Path -Path "./.github/workflows/env.ps1")) -{ - Throw "No env file found as ./github/workflows/env.ps1 !" -} - -./.github/workflows/env.ps1 - -$arg = @() -# 输出配置 -$arg += @("--standalone") -$arg += @("--output-dir=build/nuitka-mac") -$arg += @("--company-name=tool-shenjack-workshop") -$arg += @("--product-name=Difficult-Rocket") -$arg += @("--product-version=$env:DR_version") -$arg += @("--file-version=$env:Build_version") -$arg += @("--file-description=Difficult-Rocket!") -$arg += @("--macos-app-icon=textures/icon.png") -# 编译器配置 -$arg += @("--clang") -$arg += @("--lto=no") -# 包配置 -$arg += @("--nofollow-import-to=objprint,pillow,PIL,cffi,pydoc") -$arg += @("--follow-import-to=pyglet") -# 数据配置 -$arg += @("--include-data-dir=./libs/fonts=./libs/fonts") -$arg += @("--include-data-dir=./textures=./textures") -$arg += @("--include-data-dir=./configs=./configs") -$arg += @("--include-package=Difficult_Rocket.api") -# 编译配置 -$arg += @("--show-memory") -$arg += @("--show-progress") -python3.9 -m nuitka $arg $args DR.py - -$end_time = Get-Uptime -$out = $end_time.TotalMilliseconds - $start_time.TotalMilliseconds - -Write-Output $end_time.TotalSeconds $start_time.TotalSeconds $out s -Write-Output $start_time $end_time -Write-Output "--clang --lto=no and ($args)" - -# --include-data-dir=./libs/pyglet=./pyglet -# --run -# --disable-ccache diff --git a/nuitka-win.ps1 b/nuitka-win.ps1 deleted file mode 100644 index c0df9b1..0000000 --- a/nuitka-win.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -$start_time = Get-Uptime -Write-Output $start_time - -python .\.github\workflows\get_info.py -env - -if (-Not (Test-Path -Path "./.github/workflows/env.ps1")) -{ - Throw "No env file found as ./github/workflows/env.ps1 !" -} - -./.github/workflows/env.ps1 - -$arg = @() -# 输出配置 -$arg += @("--standalone") -$arg += @("--output-dir=build/nuitka-win") -$arg += @("--company-name=tool-shenjack-workshop") -$arg += @("--product-name=Difficult-Rocket") -$arg += @("--product-version=$env:DR_version") -$arg += @("--file-version=$env:Build_version") -$arg += @("--file-description=Difficult-Rocket!") -$arg += @("--windows-icon-from-ico=textures/icon.png") -#$arg += @("--macos-app-icon=textures/icon.png") -# 编译器配置 -$arg += @("--msvc=latest") -$arg += @("--clang") -$arg += @("--lto=no") -# 包配置 -$arg += @("--nofollow-import-to=objprint,pillow,PIL,cffi,pydoc") -$arg += @("--follow-import-to=pyglet") -# 数据配置 -$arg += @("--include-data-dir=./libs/fonts=./libs/fonts") -$arg += @("--include-data-dir=./textures=./textures") -$arg += @("--include-data-dir=./configs=./configs") -$arg += @("--include-package=Difficult_Rocket.api") -# 编译配置 -$arg += @("--show-memory") -$arg += @("--show-progress") -python3.8.exe -m nuitka $arg $args DR.py - -$end_time = Get-Uptime -$out = $end_time.TotalMilliseconds - $start_time.TotalMilliseconds -Write-Output $end_time.TotalSeconds $start_time.TotalSeconds $out s -Write-Output $start_time $end_time -Write-Output "--clang --msvc=latest --lto=no and $args" - -# --include-data-dir=./libs/pyglet=./pyglet -# --run -# --disable-ccache diff --git a/pyproject.toml b/pyproject.toml index dd92ec0..8b0a594 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "pdm.pep517.api" [project] name = "difficult-rocket" -version = "0.8.0.0" +version = "0.8.1.0" description = "A rocket game" authors = [ {name = "shenjackyuanjie", email = "3695888@qq.com"} -- 2.45.2 From 97b6e3cdaf5e27d7ccfc1d6e3ad6c038390cc3ae Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 16:23:32 +0800 Subject: [PATCH 04/29] update requirement --- README.md | 4 ++-- docs/README-en.md | 29 +++++++++++++++-------------- requirement-build.txt | 10 +++++----- requirement-dev.txt | 10 +++++----- requirement.txt | 2 +- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index a69db7a..9f99b9c 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ - wheel `0.40.0` - setuptools `67.6.1` - setuptools-rust `1.5.2` - - `AMD R5 5600X` - - `AMD RX 550 4G` + - `AMD R5 5600X` + - `AMD RX 550 4G` ## 需要的 Python 模块 diff --git a/docs/README-en.md b/docs/README-en.md index d85a0fa..acedd92 100644 --- a/docs/README-en.md +++ b/docs/README-en.md @@ -42,20 +42,21 @@ ## Environment (been tested / developed on) - `Develop platform 1 - Windows 10 x64 22H2` - - pillow `9.5.0` - - psutil `5.9.5` - - rtoml `0.9.0` - - tomlkit `0.11.7` - - defusedxml `0.7.1` - - objprint `0.2.2` - - viztracer `0.15.6` - - vizplugins `0.1.3` - - nuitka `1.5.6` - - ordered-set `4.1.0` - - imageio `2.27.0` - - wheel `0.40.0` - - setuptools `67.6.1` - - setuptools-rust `1.5.2` + - Python `3.8.10` + - pillow `9.5.0` + - psutil `5.9.5` + - rtoml `0.9.0` + - tomlkit `0.11.8` + - defusedxml `0.7.1` + - objprint `0.2.2` + - viztracer `0.15.6` + - vizplugins `0.1.3` + - nuitka `1.6.1` + - ordered-set `4.1.0` + - imageio `2.31.0` + - wheel `0.40.0` + - setuptools `67.8.0` + - setuptools-rust `1.6.0` - `AMD R5 5600X` - `AMD RX 550 4G` diff --git a/requirement-build.txt b/requirement-build.txt index 0cf404a..fdbaff7 100644 --- a/requirement-build.txt +++ b/requirement-build.txt @@ -10,16 +10,16 @@ psutil >= 5.9.5 # for files rtoml >= 0.9.0 -tomlkit >= 0.11.7 +tomlkit >= 0.11.8 defusedxml >= 0.7.1 # for report error objprint >= 0.2.2 # for compile -nuitka >= 1.5.6 +nuitka >= 1.6.1 ordered-set >= 4.1.0 -imageio >= 2.27.0 +imageio >= 2.31.0 wheel >= 0.40.0 -setuptools >= 67.6.1 -setuptools-rust >= 1.5.2 +setuptools >= 67.8.0 +setuptools-rust >= 1.6.0 diff --git a/requirement-dev.txt b/requirement-dev.txt index e35ba51..536bc21 100644 --- a/requirement-dev.txt +++ b/requirement-dev.txt @@ -11,7 +11,7 @@ psutil >= 5.9.5 # for files rtoml >= 0.9.0 -tomlkit >= 0.11.7 +tomlkit >= 0.11.8 defusedxml >= 0.7.1 # for debug @@ -20,9 +20,9 @@ viztracer >= 0.15.6 vizplugins >= 0.1.3 # for compile -nuitka >= 1.5.6 +nuitka >= 1.6.1 ordered-set >= 4.1.0 -imageio >= 2.27.0 +imageio >= 2.31.0 wheel >= 0.40.0 -setuptools >= 67.6.1 -setuptools-rust >= 1.5.2 +setuptools >= 67.8.0 +setuptools-rust >= 1.6.0 diff --git a/requirement.txt b/requirement.txt index d45edc1..ac42cd7 100644 --- a/requirement.txt +++ b/requirement.txt @@ -9,7 +9,7 @@ psutil >= 5.9.5 # for files rtoml >= 0.9.0 -tomlkit >= 0.11.7 +tomlkit >= 0.11.8 defusedxml >= 0.7.1 # for report error -- 2.45.2 From 4ceed8832944809d57d8084751975ff9ade70795 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 16:26:54 +0800 Subject: [PATCH 05/29] add requirement change to workflow --- .github/workflows/dr_rs.yml | 2 ++ .github/workflows/nuitka.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/dr_rs.yml b/.github/workflows/dr_rs.yml index 4e54b7c..0b44c3e 100644 --- a/.github/workflows/dr_rs.yml +++ b/.github/workflows/dr_rs.yml @@ -8,10 +8,12 @@ on: paths: - "mods/dr_game/**" # 本体修改 - ".github/workflows/**" # workflow 修改 + - "requirements*" # 依赖修改 pull_request: paths: - "mods/dr_game/**" # 本体修改 - ".github/workflows/**" # workflow 修改 + - "requirements*" # 依赖修改 workflow_dispatch: # 主任务 diff --git a/.github/workflows/nuitka.yml b/.github/workflows/nuitka.yml index 0e4d014..e869c32 100644 --- a/.github/workflows/nuitka.yml +++ b/.github/workflows/nuitka.yml @@ -10,12 +10,14 @@ on: - "configs/**" # 配置修改 - "libs/pyglet/**" # pyglet 修改 - ".github/workflows/**" # workflow 修改 + - "requirements*" # 依赖修改 pull_request: paths: - "Difficult_Rocket/**" # 本体修改 - "configs/**" # 配置修改 - "libs/pyglet/**" # pyglet 修改 - ".github/workflows/**" # workflow 修改 + - "requirements*" # 依赖修改 workflow_dispatch: # 主任务 -- 2.45.2 From e7448d05f0958b4272cb376fbcab66ca839b7c7b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 16:29:28 +0800 Subject: [PATCH 06/29] add 2.0.0.0 planing changes --- docs/src/change_log/build_file.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/src/change_log/build_file.md b/docs/src/change_log/build_file.md index a324045..7f6c138 100644 --- a/docs/src/change_log/build_file.md +++ b/docs/src/change_log/build_file.md @@ -4,9 +4,14 @@ - 最新构建版本号 - build_version: 1.3.0.0 +## 20230609 build 2.0.0.0 +### Breaking Change -## 20230609 build 1.3.0.0 +- 将构建脚本生成方式改为通过 `libs/utils/nuitka.py` 生成 +- + +## 202306 build 1.3.0.0 - 修改 - 向 `bifollow-import-to` 添加 `pydoc` -- 2.45.2 From 4ddeddf88a840b3f5556be6c471006bc0ead3bc1 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 16:57:26 +0800 Subject: [PATCH 07/29] impl done? --- libs/utils/nuitka.py | 8 +++++--- nuitka_build.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libs/utils/nuitka.py b/libs/utils/nuitka.py index 7b327a5..573c33c 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -19,6 +19,8 @@ class Status(Options): output_path: Path = Path("./build/nuitka-win") src_file: Path = Path('DR.py') + python_cmd: str = 'python' + # 以下为 nuitka 的参数 use_lto: bool = False # --lto=yes (no is faster) use_clang: bool = True # --clang @@ -36,13 +38,13 @@ class Status(Options): icon_path: Path = Path('textures/icon.png') - follow_import: List[str] = ['pyglet', 'Difficult_Rocket.api'] + follow_import: List[str] = ['pyglet'] no_follow_import: List[str] = ['objprint', 'pillow', 'PIL', 'cffi', 'pydoc', 'numpy'] include_data_dir: List[Tuple[Path, Path]] = [(Path('./libs/fonts'), Path('./libs/fonts')), (Path('./textures'), Path('./textures')), (Path('./configs'), Path('./configs'))] - include_packages: List[str] = [] + include_packages: List[str] = ['Difficult_Rocket.api'] def init(self, **kwargs) -> None: # 非 windows 平台不使用 msvc @@ -72,7 +74,7 @@ class Status(Options): return f"{front}\n\n```bash\n{' '.join(gen_cmd)}\n```" def gen_subprocess_cmd(self) -> List[str]: - cmd_list = ['python', '-m', 'nuitka'] + cmd_list = [self.python_cmd, '-m', 'nuitka'] # macos 和 非 macos icon 参数不同 icon_cmd = "" if platform.system() == 'Darwin': diff --git a/nuitka_build.py b/nuitka_build.py index 1fa56a9..08fc85c 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -4,13 +4,43 @@ # All rights reserved # ------------------------------- +import sys +import time import subprocess from libs.utils import nuitka if __name__ == '__main__': compiler = nuitka.Status() + # 修改 python 执行文件 为 运行时的 python + compiler.python_cmd = sys.executable + + # 检测 --output xx 参数 + if '--output' in sys.argv: + # 输入的是输出目录 + compiler.output_path = sys.argv[sys.argv.index('--output') + 1] + sys.argv.remove('--output') + sys.argv.remove(compiler.output_path) + + print(compiler.output_path) + print(compiler) print(compiler.gen_subprocess_cmd()) + # 确认是否需要编译 + # 如果包含 -y 参数 则直接编译 + if ('-y' or '-n') not in sys.argv: + while (do_compile := input('Do you want to compile this file? (y/n) ')) not in ['y', 'n']: + pass + elif '-y' in sys.argv: + do_compile = 'y' + else: + do_compile = 'n' + + if do_compile == 'y': + # 编译 + start_time = time.time_ns() + subprocess.run(compiler.gen_subprocess_cmd()) + print('Compile Done!') + print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000000000} s)') -- 2.45.2 From 9ca58e63971f75de94bed2e117f25f5bc6889fd4 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 17:03:35 +0800 Subject: [PATCH 08/29] add more implment --- libs/utils/nuitka.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/utils/nuitka.py b/libs/utils/nuitka.py index 573c33c..777f198 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -27,10 +27,13 @@ class Status(Options): use_msvc: bool = True # --msvc=latest use_mingw: bool = False # --mingw64 standalone: bool = True # --standalone + use_ccache: bool = True # not --disable-ccache show_progress: bool = True # --show-progress show_memory: bool = False # --show-memory + download_confirm: bool = True # --assume-yes-for-download + company_name: str = 'tool-shenjack-workshop' product_name: str = 'Difficult-Rocket' product_version: Version @@ -41,9 +44,9 @@ class Status(Options): follow_import: List[str] = ['pyglet'] no_follow_import: List[str] = ['objprint', 'pillow', 'PIL', 'cffi', 'pydoc', 'numpy'] - include_data_dir: List[Tuple[Path, Path]] = [(Path('./libs/fonts'), Path('./libs/fonts')), - (Path('./textures'), Path('./textures')), - (Path('./configs'), Path('./configs'))] + include_data_dir: List[Tuple[str, str]] = [('./libs/fonts', './libs/fonts'), + ('./textures', './textures'), + ('./configs', './configs')] include_packages: List[str] = ['Difficult_Rocket.api'] def init(self, **kwargs) -> None: @@ -86,16 +89,21 @@ class Status(Options): cmd_list.append('--lto=yes') else: cmd_list.append('--lto=no') + if self.use_clang: cmd_list.append('--clang') if self.use_msvc: cmd_list.append('--msvc=latest') if self.standalone: cmd_list.append('--standalone') + if not self.use_ccache: + cmd_list.append('--disable-ccache') if self.show_progress: cmd_list.append('--show-progress') if self.show_memory: cmd_list.append('--show-memory') + if self.download_confirm: + cmd_list.append('--assume-yes-for-download') cmd_list.append(f"--output-dir={self.output_path.absolute()}") @@ -114,5 +122,3 @@ class Status(Options): cmd_list.append(f"{self.src_file}") return cmd_list - - -- 2.45.2 From 9cc98d3500df6d5c906c5d22d36b3977969931e2 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 17:04:17 +0800 Subject: [PATCH 09/29] add config for github compile --- nuitka_build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nuitka_build.py b/nuitka_build.py index 08fc85c..9f91455 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -22,6 +22,10 @@ if __name__ == '__main__': sys.argv.remove('--output') sys.argv.remove(compiler.output_path) + # 检测 --github 参数 + if '--github' in sys.argv: + compiler.use_ccache = False + print(compiler.output_path) print(compiler) -- 2.45.2 From 6714e4c24cfbd258e9a48c0498c1452736d1ea63 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 9 Jun 2023 17:05:14 +0800 Subject: [PATCH 10/29] good job! --- nuitka_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuitka_build.py b/nuitka_build.py index 9f91455..3ded22f 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -47,4 +47,4 @@ if __name__ == '__main__': start_time = time.time_ns() subprocess.run(compiler.gen_subprocess_cmd()) print('Compile Done!') - print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000000000} s)') + print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000_000_000} s)') -- 2.45.2 From 3ac6e8a54e65a1d2bfc5d7477958e7a19598771b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 14:45:51 +0800 Subject: [PATCH 11/29] update some nuitka build --- libs/utils/nuitka.py | 4 ++-- nuitka_build.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/utils/nuitka.py b/libs/utils/nuitka.py index 777f198..87c71fc 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -13,8 +13,8 @@ from typing import List, Tuple from Difficult_Rocket.api.types import Options, Version -class Status(Options): - name = 'Nuitka Build Status' +class CompilerHelper(Options): + name = 'Nuitka Compiler Helper' output_path: Path = Path("./build/nuitka-win") src_file: Path = Path('DR.py') diff --git a/nuitka_build.py b/nuitka_build.py index 3ded22f..7cdba71 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -10,7 +10,7 @@ import subprocess from libs.utils import nuitka if __name__ == '__main__': - compiler = nuitka.Status() + compiler = nuitka.CompilerHelper() # 修改 python 执行文件 为 运行时的 python compiler.python_cmd = sys.executable -- 2.45.2 From 58796cd79c569a380d2f2e65d7944d30ef418c01 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 14:46:19 +0800 Subject: [PATCH 12/29] update cargo dependency --- .../Difficult_Rocket_rs/src/Cargo.lock | 135 ++++++++---------- .../Difficult_Rocket_rs/src/Cargo.toml | 4 +- mods/dr_game/Difficult_Rocket_rs/src/setup.py | 7 +- 3 files changed, 68 insertions(+), 78 deletions(-) diff --git a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock index 1c583e2..f4569ed 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock +++ b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -145,21 +145,21 @@ checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.146" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" [[package]] name = "libm" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -167,19 +167,17 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "matrixmultiply" -version = "0.3.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" dependencies = [ + "autocfg", "rawpointer", ] @@ -272,9 +270,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "optional" @@ -294,22 +292,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-targets", ] [[package]] name = "parry2d-f64" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1bf555d44a3be6c6b6acdea1614af50b12987b4b9651c812d3219e8136c336" +checksum = "2f612055f319eb83e67841fdf00248eee26045a1759b5d94fa9c6ecce7c1e78d" dependencies = [ "approx", "arrayvec", @@ -334,9 +332,9 @@ checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -403,9 +401,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -439,9 +437,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -460,9 +458,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "safe_arch" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" dependencies = [ "bytemuck", ] @@ -475,9 +473,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] @@ -496,13 +494,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.18", ] [[package]] @@ -535,9 +533,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "spade" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1190e0e8f4eb17fc3dbb2d20e1142676e56aaac3daede39f64a3302d687b80f3" +checksum = "88e65803986868d2372c582007c39ba89936a36ea5f236bf7a7728dc258f04f9" dependencies = [ "num-traits", "optional", @@ -558,9 +556,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", @@ -569,9 +567,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "thiserror" @@ -590,7 +588,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.18", ] [[package]] @@ -601,9 +599,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unindent" @@ -619,28 +617,19 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "wide" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b689b6c49d6549434bf944e6b0f39238cf63693cb7a147e9d887507fffa3b223" +checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" dependencies = [ "bytemuck", "safe_arch", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -653,48 +642,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "xml-rs" -version = "0.8.10" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc95a04ea24f543cd9be5aab44f963fa35589c99e18415c38fb2b17e133bf8d2" +checksum = "52839dc911083a8ef63efa4d039d1f58b5e409f923e44c80828f206f66e5541c" diff --git a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml index b563714..c787117 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml +++ b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml @@ -23,11 +23,11 @@ codegen-units = 1 #features = ["serialize"] [dependencies.serde] -version = "1.0.163" +version = "1.0.164" features = ["derive"] [dependencies.xml-rs] -version = "0.8.10" +version = "0.8.14" [dependencies.serde-xml-rs] version = "0.6.0" diff --git a/mods/dr_game/Difficult_Rocket_rs/src/setup.py b/mods/dr_game/Difficult_Rocket_rs/src/setup.py index 1030175..a362c4d 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/setup.py +++ b/mods/dr_game/Difficult_Rocket_rs/src/setup.py @@ -6,17 +6,18 @@ import sys import shutil from setuptools import setup -from setuptools_rust import Binding, RustExtension +from setuptools_rust import Binding, RustExtension, Strip package_path = 'Difficult_Rocket_rs' setup( name='Difficult_Rocket_rs', - version="0.2.9.3", + version="0.2.10.1", author='shenjackyuanjie', author_email='3695888@qq.com', rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs", - binding=Binding.PyO3)], + binding=Binding.PyO3, + strip=Strip.All)], zip_safe=False, ) -- 2.45.2 From 50f35ee138382ab7e6ddfe7db7bcf36e13c3ff0c Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:10:44 +0800 Subject: [PATCH 13/29] add more github compat --- nuitka_build.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nuitka_build.py b/nuitka_build.py index 7cdba71..7447e14 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -6,7 +6,12 @@ import sys import time +import shutil +import zipfile import subprocess + +from pathlib import Path + from libs.utils import nuitka if __name__ == '__main__': @@ -23,8 +28,12 @@ if __name__ == '__main__': sys.argv.remove(compiler.output_path) # 检测 --github 参数 + is_github = False if '--github' in sys.argv: + is_github = True compiler.use_ccache = False + compiler.show_progress = False + compiler.output_path = Path('./build/github') print(compiler.output_path) @@ -34,11 +43,13 @@ if __name__ == '__main__': # 确认是否需要编译 # 如果包含 -y 参数 则直接编译 - if ('-y' or '-n') not in sys.argv: + if ('-y' or '-n') not in sys.argv or not is_github: while (do_compile := input('Do you want to compile this file? (y/n) ')) not in ['y', 'n']: pass elif '-y' in sys.argv: do_compile = 'y' + elif is_github: + do_compile = 'y' else: do_compile = 'n' @@ -48,3 +59,5 @@ if __name__ == '__main__': subprocess.run(compiler.gen_subprocess_cmd()) print('Compile Done!') print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000_000_000} s)') + if is_github: + subprocess.run(['python', 'libs/utils/github.py', compiler.output_path]) -- 2.45.2 From 091f0baa98553703fa7b06836998d8150432db3b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:36:44 +0800 Subject: [PATCH 14/29] move import. add more github compile compat --- .github/workflows/post_compile.py | 2 +- nuitka_build.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/post_compile.py b/.github/workflows/post_compile.py index 23ed768..9db290a 100644 --- a/.github/workflows/post_compile.py +++ b/.github/workflows/post_compile.py @@ -6,8 +6,8 @@ import os import sys -import zipfile import shutil +import zipfile if sys.platform == "win32": os.system('') diff --git a/nuitka_build.py b/nuitka_build.py index 7447e14..a4e7510 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -4,6 +4,7 @@ # All rights reserved # ------------------------------- +import os import sys import time import shutil @@ -60,4 +61,17 @@ if __name__ == '__main__': print('Compile Done!') print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000_000_000} s)') if is_github: - subprocess.run(['python', 'libs/utils/github.py', compiler.output_path]) + # 去除无用字体文件 + shutil.rmtree(compiler.output_path / 'fonts' / 'Fira_Code', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'fonts' / 'scientifica', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) + os.remove(compiler.output_path / 'fonts' / 'Monocraft.otf') + os.remove(compiler.output_path / 'fonts' / 'SmileySans-Oblique.ttf') + # 压缩 + with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: + for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): + print(f'writing {path}') + for file in sub_files: + file_path = os.path.join(path, file) + dist_zip.write(file_path) -- 2.45.2 From 69e16e1cc046a006699982c0d86df51839b4b643 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:37:30 +0800 Subject: [PATCH 15/29] add compile script change to path --- .github/workflows/nuitka.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nuitka.yml b/.github/workflows/nuitka.yml index e869c32..cb03f2b 100644 --- a/.github/workflows/nuitka.yml +++ b/.github/workflows/nuitka.yml @@ -10,6 +10,7 @@ on: - "configs/**" # 配置修改 - "libs/pyglet/**" # pyglet 修改 - ".github/workflows/**" # workflow 修改 + - "nuitka_build.py" # 构建脚本修改 - "requirements*" # 依赖修改 pull_request: paths: @@ -17,6 +18,7 @@ on: - "configs/**" # 配置修改 - "libs/pyglet/**" # pyglet 修改 - ".github/workflows/**" # workflow 修改 + - "nuitka_build.py" # 构建脚本修改 - "requirements*" # 依赖修改 workflow_dispatch: -- 2.45.2 From 71410eb2e82baa8403f324f60ef9cb3c850598fd Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:39:50 +0800 Subject: [PATCH 16/29] try new compile action --- .github/workflows/nuitka.yml | 122 +++++++++++------------------------ 1 file changed, 37 insertions(+), 85 deletions(-) diff --git a/.github/workflows/nuitka.yml b/.github/workflows/nuitka.yml index cb03f2b..1fa35ac 100644 --- a/.github/workflows/nuitka.yml +++ b/.github/workflows/nuitka.yml @@ -43,20 +43,6 @@ jobs: - name: Checkout code uses: nschloe/action-cached-lfs-checkout@v1 - # 获取短 sha - - name: Get short commit sha - id: get_short_sha - shell: pwsh - run: | - # short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) - # echo "short_sha=$short_sha" >> $GITHUB_OUTPUT - # echo $GITHUB_OUTPUT - $short_sha = Write-Output $env:GITHUB_SHA - $short_sha = $short_sha.substring(1,7) - Write-Output $short_sha - Write-Output "short_sha=$short_sha" >> $env:GITHUB_ENV - - # 安装 Python - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v4 @@ -95,83 +81,49 @@ jobs: Write-Output $infos >> $env:GITHUB_ENV python .github/workflows/get_info.py - # 还是得我自己写脚本 - - name: Build on Windows - if: runner.os == 'Windows' + # 使用新的 nuitka_build.py + - name: Build by nuitka shell: pwsh run: | - $arg = @() - # 输出配置 - $arg += @("--standalone") - $arg += @("--output-dir=build") - $arg += @("--company-name=tool-shenjack-workshop") - $arg += @("--product-name=Difficult-Rocket") - $arg += @("--product-version=$env:DR_version") - $arg += @("--file-version=$env:Build_version") - $arg += @("--file-description=Difficult-Rocket!") - $arg += @("--windows-icon-from-ico=textures/icon.png") - # $arg += @("--macos-app-icon=textures/icon.png") - # 编译器配置 - $arg += @("--msvc=latest") - $arg += @("--clang") - $arg += @("--lto=no") - # 包配置 - $arg += @("--nofollow-import-to=objprint,pillow,PIL,cffi") - $arg += @("--follow-import-to=pyglet") - # 数据配置 - $arg += @("--include-data-dir=./textures=./textures") - $arg += @("--include-data-dir=./configs=./configs") - # 编译配置 - $arg += @("--disable-ccache") - $arg += @("--assume-yes-for-download") - python -m nuitka $arg DR.py + python nuitka_build.py --github + # 集成的构建脚本 好耶! - - name: Build on MacOS / Linux - if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} + # - name: after build + # shell: pwsh + # run: | + # Get-ChildItem libs/fonts/Fira_Code -Recurse | Remove-Item -Force + # Get-ChildItem libs/fonts/scientifica -Recurse | Remove-Item -Force + # Remove-Item libs/fonts/Monocraft.otf -Force + # Remove-Item libs/fonts/SmileySans-Oblique.ttf -Force + # Get-ChildItem libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans_Condensed/* -Recurse | Remove-Item -Force + # Get-ChildItem libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans/* -Recurse | Remove-Item -Force + # + # Copy-Item libs/fonts build\DR.dist\libs\fonts -Recurse + # # Copy-Item libs\pyglet\ build\DR.dist -Recurse + # + # Rename-Item build/DR.dist Difficult-Rocket + # python ./.github/workflows/post_compile.py + + + upload-artifact: + runs-on: ubuntu-latest + + needs: + - build-nuitka + + steps: + + # 获取短 sha + - name: Get short commit sha + id: get_short_sha shell: pwsh run: | - $arg = @() - # 输出配置 - $arg += @("--standalone") - $arg += @("--output-dir=build") - $arg += @("--company-name=tool-shenjack-workshop") - $arg += @("--product-name=Difficult-Rocket") - $arg += @("--product-version=$env:DR_version") - $arg += @("--file-version=$env:Build_version") - $arg += @("--file-description=Difficult-Rocket!") - # $arg += @("--windows-icon-from-ico=textures/icon.png") - $arg += @("--macos-app-icon=textures/icon.png") - # 编译器配置 - $arg += @("--clang") - $arg += @("--lto=no") - # 包配置 - $arg += @("--nofollow-import-to=objprint,pillow,PIL,cffi") - $arg += @("--follow-import-to=pyglet") - # 数据配置 - $arg += @("--include-data-dir=./textures=./textures") - $arg += @("--include-data-dir=./configs=./configs") - # 编译配置 - $arg += @("--disable-ccache") - $arg += @("--assume-yes-for-download") - python -m nuitka $arg DR.py + $short_sha = Write-Output $env:GITHUB_SHA + $short_sha = $short_sha.substring(1,7) + Write-Output $short_sha + Write-Output "short_sha=$short_sha" >> $env:GITHUB_ENV - - name: after build - shell: pwsh - run: | - Get-ChildItem libs/fonts/Fira_Code -Recurse | Remove-Item -Force - Get-ChildItem libs/fonts/scientifica -Recurse | Remove-Item -Force - Remove-Item libs/fonts/Monocraft.otf -Force - Remove-Item libs/fonts/SmileySans-Oblique.ttf -Force - Get-ChildItem libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans_Condensed/* -Recurse | Remove-Item -Force - Get-ChildItem libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans/* -Recurse | Remove-Item -Force - - Copy-Item libs/fonts build\DR.dist\libs\fonts -Recurse - # Copy-Item libs\pyglet\ build\DR.dist -Recurse - - Rename-Item build/DR.dist Difficult-Rocket - python ./.github/workflows/post_compile.py - - # Uploads artifact + # Uploads artifact - name: Upload Artifact uses: actions/upload-artifact@v3 with: -- 2.45.2 From 258c1cea96e51b7782783272aa36b7264f9a64c4 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:43:30 +0800 Subject: [PATCH 17/29] and not or --- nuitka_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuitka_build.py b/nuitka_build.py index a4e7510..8172ed3 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -44,7 +44,7 @@ if __name__ == '__main__': # 确认是否需要编译 # 如果包含 -y 参数 则直接编译 - if ('-y' or '-n') not in sys.argv or not is_github: + if (('-y' or '-n') not in sys.argv) and (not is_github): while (do_compile := input('Do you want to compile this file? (y/n) ')) not in ['y', 'n']: pass elif '-y' in sys.argv: -- 2.45.2 From d8bec01a86ca73750f458e6eccf5c0a9db5e36c9 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:45:22 +0800 Subject: [PATCH 18/29] add compile path --- nuitka_build.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nuitka_build.py b/nuitka_build.py index 8172ed3..9d0ae60 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -62,12 +62,12 @@ if __name__ == '__main__': print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000_000_000} s)') if is_github: # 去除无用字体文件 - shutil.rmtree(compiler.output_path / 'fonts' / 'Fira_Code', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'fonts' / 'scientifica', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) - os.remove(compiler.output_path / 'fonts' / 'Monocraft.otf') - os.remove(compiler.output_path / 'fonts' / 'SmileySans-Oblique.ttf') + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'Fira_Code', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'scientifica', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) + os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'Monocraft.otf') + os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'SmileySans-Oblique.ttf') # 压缩 with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): -- 2.45.2 From 5619699ebf484f30147b75df9d7f09bab1b674e9 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:45:51 +0800 Subject: [PATCH 19/29] =?UTF-8?q?=E6=8A=8Agithub=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=94=BE=E5=88=B0=20output=E5=8F=82=E6=95=B0=E5=89=8D=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nuitka_build.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nuitka_build.py b/nuitka_build.py index 9d0ae60..2d7e3f3 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -21,13 +21,6 @@ if __name__ == '__main__': # 修改 python 执行文件 为 运行时的 python compiler.python_cmd = sys.executable - # 检测 --output xx 参数 - if '--output' in sys.argv: - # 输入的是输出目录 - compiler.output_path = sys.argv[sys.argv.index('--output') + 1] - sys.argv.remove('--output') - sys.argv.remove(compiler.output_path) - # 检测 --github 参数 is_github = False if '--github' in sys.argv: @@ -36,6 +29,13 @@ if __name__ == '__main__': compiler.show_progress = False compiler.output_path = Path('./build/github') + # 检测 --output xx 参数 + if '--output' in sys.argv: + # 输入的是输出目录 + compiler.output_path = sys.argv[sys.argv.index('--output') + 1] + sys.argv.remove('--output') + sys.argv.remove(compiler.output_path) + print(compiler.output_path) print(compiler) -- 2.45.2 From e6edaa9cd28c4a700a99a826a4d43e461dde668d Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:48:52 +0800 Subject: [PATCH 20/29] try use sys.argv[0] instead --- nuitka_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuitka_build.py b/nuitka_build.py index 2d7e3f3..12d78d5 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -19,7 +19,7 @@ if __name__ == '__main__': compiler = nuitka.CompilerHelper() # 修改 python 执行文件 为 运行时的 python - compiler.python_cmd = sys.executable + compiler.python_cmd = sys.argv[0] # 检测 --github 参数 is_github = False -- 2.45.2 From 861d9d2af295d436949d35e77ddd58382178f7c2 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:52:49 +0800 Subject: [PATCH 21/29] Nan roll back --- nuitka_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuitka_build.py b/nuitka_build.py index 12d78d5..2d7e3f3 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -19,7 +19,7 @@ if __name__ == '__main__': compiler = nuitka.CompilerHelper() # 修改 python 执行文件 为 运行时的 python - compiler.python_cmd = sys.argv[0] + compiler.python_cmd = sys.executable # 检测 --github 参数 is_github = False -- 2.45.2 From b16be1b9fb5a7fed9880cd190ac1734f8e1062e1 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 15:54:36 +0800 Subject: [PATCH 22/29] try replace back? --- nuitka_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nuitka_build.py b/nuitka_build.py index 2d7e3f3..9368e70 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -28,6 +28,7 @@ if __name__ == '__main__': compiler.use_ccache = False compiler.show_progress = False compiler.output_path = Path('./build/github') + compiler.python_cmd = 'python' # 检测 --output xx 参数 if '--output' in sys.argv: -- 2.45.2 From e75d4171affaa7a796926e7026bda2b0e2627a26 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 16:10:53 +0800 Subject: [PATCH 23/29] you wait and see --- nuitka_build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nuitka_build.py b/nuitka_build.py index 9368e70..ea75542 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -57,6 +57,7 @@ if __name__ == '__main__': if do_compile == 'y': # 编译 + time.sleep(1) # 等待 1s start_time = time.time_ns() subprocess.run(compiler.gen_subprocess_cmd()) print('Compile Done!') @@ -69,6 +70,7 @@ if __name__ == '__main__': shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'Monocraft.otf') os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'SmileySans-Oblique.ttf') + print('Remove Useless Files Done!') # 压缩 with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): @@ -76,3 +78,4 @@ if __name__ == '__main__': for file in sub_files: file_path = os.path.join(path, file) dist_zip.write(file_path) + print('Zip Done!') -- 2.45.2 From 00e753a500f2be177f8d0654b12d3354e109c7d9 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 16:11:17 +0800 Subject: [PATCH 24/29] exit code 0! --- nuitka_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nuitka_build.py b/nuitka_build.py index ea75542..7b0604b 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -79,3 +79,4 @@ if __name__ == '__main__': file_path = os.path.join(path, file) dist_zip.write(file_path) print('Zip Done!') + sys.exit(0) -- 2.45.2 From 8aca038cf6db81dbc86dcdf2f819c00baf50a470 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 16:25:47 +0800 Subject: [PATCH 25/29] add if to icon_cmd --- libs/utils/nuitka.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/utils/nuitka.py b/libs/utils/nuitka.py index 87c71fc..eddd864 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -112,7 +112,8 @@ class CompilerHelper(Options): cmd_list.append(f"--product-version={self.product_version}") cmd_list.append(f"--file-version={self.file_version}") - cmd_list.append(icon_cmd) + if icon_cmd: + cmd_list.append(icon_cmd) cmd_list += [f"--include-data-dir={src}={dst}" for src, dst in self.include_data_dir] cmd_list += [f"--include-package={package}" for package in self.include_packages] -- 2.45.2 From 94b4c1bb4fb787988d25e28c9684fad604983e2b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 16:30:44 +0800 Subject: [PATCH 26/29] add traceback --- nuitka_build.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/nuitka_build.py b/nuitka_build.py index 7b0604b..da42805 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -9,6 +9,7 @@ import sys import time import shutil import zipfile +import traceback import subprocess from pathlib import Path @@ -64,12 +65,15 @@ if __name__ == '__main__': print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000_000_000} s)') if is_github: # 去除无用字体文件 - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'Fira_Code', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'scientifica', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) - os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'Monocraft.otf') - os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'SmileySans-Oblique.ttf') + try: + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'Fira_Code', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'scientifica', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) + os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'Monocraft.otf') + os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'SmileySans-Oblique.ttf') + except Exception: + traceback.print_exc() print('Remove Useless Files Done!') # 压缩 with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: -- 2.45.2 From d1baf547a02007e15cd89abeb2fea2ddec0fcc08 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 16:42:54 +0800 Subject: [PATCH 27/29] add libs path --- nuitka_build.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nuitka_build.py b/nuitka_build.py index da42805..0be5ab0 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -66,12 +66,12 @@ if __name__ == '__main__': if is_github: # 去除无用字体文件 try: - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'Fira_Code', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'scientifica', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) - shutil.rmtree(compiler.output_path / 'DR.dist' / 'fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) - os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'Monocraft.otf') - os.remove(compiler.output_path / 'DR.dist' / 'fonts' / 'SmileySans-Oblique.ttf') + shutil.rmtree(compiler.output_path / 'DR.dist/libs/fonts' / 'Fira_Code', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist/libs/fonts' / 'scientifica', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist/libs/fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans_Condensed', ignore_errors=True) + shutil.rmtree(compiler.output_path / 'DR.dist/libs/fonts' / 'HarmonyOS_Sans' / 'HarmonyOS_Sans', ignore_errors=True) + os.remove(compiler.output_path / 'DR.dist/libs/fonts' / 'Monocraft.otf') + os.remove(compiler.output_path / 'DR.dist/libs/fonts' / 'SmileySans-Oblique.ttf') except Exception: traceback.print_exc() print('Remove Useless Files Done!') -- 2.45.2 From d62dcc2d3c17fd0df3dcfa8c6b0521eefd3589bb Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 17:09:57 +0800 Subject: [PATCH 28/29] look like useless? --- .github/workflows/nuitka.yml | 27 +-------------------------- nuitka_build.py | 14 +++++++------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/.github/workflows/nuitka.yml b/.github/workflows/nuitka.yml index 1fa35ac..b4e3e6f 100644 --- a/.github/workflows/nuitka.yml +++ b/.github/workflows/nuitka.yml @@ -88,31 +88,6 @@ jobs: python nuitka_build.py --github # 集成的构建脚本 好耶! - # - name: after build - # shell: pwsh - # run: | - # Get-ChildItem libs/fonts/Fira_Code -Recurse | Remove-Item -Force - # Get-ChildItem libs/fonts/scientifica -Recurse | Remove-Item -Force - # Remove-Item libs/fonts/Monocraft.otf -Force - # Remove-Item libs/fonts/SmileySans-Oblique.ttf -Force - # Get-ChildItem libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans_Condensed/* -Recurse | Remove-Item -Force - # Get-ChildItem libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans/* -Recurse | Remove-Item -Force - # - # Copy-Item libs/fonts build\DR.dist\libs\fonts -Recurse - # # Copy-Item libs\pyglet\ build\DR.dist -Recurse - # - # Rename-Item build/DR.dist Difficult-Rocket - # python ./.github/workflows/post_compile.py - - - upload-artifact: - runs-on: ubuntu-latest - - needs: - - build-nuitka - - steps: - # 获取短 sha - name: Get short commit sha id: get_short_sha @@ -129,4 +104,4 @@ jobs: with: name: Difficult-Rocket_v${{env.DR_version}}-${{runner.os}}${{matrix.python-version}}-Build.${{github.run_number}}+${{env.short_sha}} path: | - build/main.zip + build/github/DR.dist diff --git a/nuitka_build.py b/nuitka_build.py index 0be5ab0..d1559f2 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -76,11 +76,11 @@ if __name__ == '__main__': traceback.print_exc() print('Remove Useless Files Done!') # 压缩 - with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: - for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): - print(f'writing {path}') - for file in sub_files: - file_path = os.path.join(path, file) - dist_zip.write(file_path) - print('Zip Done!') + # with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: + # for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): + # print(f'writing {path}') + # for file in sub_files: + # file_path = os.path.join(path, file) + # dist_zip.write(file_path) + # print('Zip Done!') sys.exit(0) -- 2.45.2 From b9363bb24561e0d3cb01cbd8847aed1591a60a03 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 18:24:24 +0800 Subject: [PATCH 29/29] use double zip --- .github/workflows/nuitka.yml | 10 +++- .github/workflows/post_compile.py | 96 ------------------------------- .github/workflows/requirement.txt | 5 -- nuitka_build.py | 14 ++--- 4 files changed, 16 insertions(+), 109 deletions(-) delete mode 100644 .github/workflows/post_compile.py delete mode 100644 .github/workflows/requirement.txt diff --git a/.github/workflows/nuitka.yml b/.github/workflows/nuitka.yml index b4e3e6f..310108f 100644 --- a/.github/workflows/nuitka.yml +++ b/.github/workflows/nuitka.yml @@ -102,6 +102,14 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: Difficult-Rocket_v${{env.DR_version}}-${{runner.os}}${{matrix.python-version}}-Build.${{github.run_number}}+${{env.short_sha}} + name: Difficult-Rocket_v${{env.DR_version}}-${{runner.os}}${{matrix.python-version}}-Build.${{github.run_number}}+${{env.short_sha}}.zip path: | build/github/DR.dist + + # Uploads artifact + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: Difficult-Rocket_v${{env.DR_version}}-${{runner.os}}${{matrix.python-version}}-Build.${{github.run_number}}+${{env.short_sha}}.zip.zip + path: | + build/Difficult_Rocket.zip diff --git a/.github/workflows/post_compile.py b/.github/workflows/post_compile.py deleted file mode 100644 index 9db290a..0000000 --- a/.github/workflows/post_compile.py +++ /dev/null @@ -1,96 +0,0 @@ -# ------------------------------- -# Difficult Rocket -# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com -# All rights reserved -# ------------------------------- - -import os -import sys -import shutil -import zipfile - -if sys.platform == "win32": - os.system('') - - -def make_zip(): - with zipfile.ZipFile('./build/main.zip', 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: - for path, sub_paths, sub_files in os.walk('./build/Difficult-Rocket'): - print(f'writing {path}') - for file in sub_files: - file_path = os.path.join(path, file) - dist_zip.write(file_path) - - -def show_files(): - print("----------") - try: - print(os.listdir('libs')) - print(os.listdir('build')) - print(os.listdir('build/libs')) - print(os.listdir('build/libs/fonts')) - print(os.listdir("build/libs/Difficult_Rocket_rs")) - except Exception as e: - print(f'list file error {e}') - print('-----------') - - -def remove_un_use(): - un_use_file = [ - 'libs/fonts/Fira_Code', - 'libs/fonts/scientifica', - 'libs/fonts/Monocraft.otf', - 'libs/fonts/SmileySans-Oblique.ttf', - 'libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans_Condensed', - 'libs/fonts/HarmonyOS_Sans/HarmonyOS_Sans', - ] - # 删除不必要的文件 - # 如果忽略不存在或无法删除的文件 - os.chdir('./build/Difficult-Rocket') - print(os.listdir()) - print(os.path.abspath(os.curdir)) - print("=============") - for the_file in un_use_file: - print(f"file: {the_file}") - try: - os.remove(the_file) - shutil.rmtree(the_file, ignore_errors=True) - print(f"origin remove {the_file}") - except PermissionError: - print(f"Permission denied at {os.path.abspath(the_file)}") - except (IsADirectoryError, FileNotFoundError): - # 如果是目录 - try: - shutil.rmtree(the_file) - print(f"remove dir {os.path.abspath(the_file)}") - except FileNotFoundError: - print(f"FileNotFoundError at {os.path.abspath(the_file)}") - print("=============") - os.chdir('../../') - - -def copy_data_file(): - files = { - 'libs/pyglet': 'build/pyglet', - 'libs/Difficult_Rocket_rs/lib': 'build/libs/Difficult_Rocket_rs/lib', - 'libs/fonts': 'build/libs/fonts' - } - # 使用 shutil 复制文件 - # os.mkdir("build/pyglet") - # os.mkdir("build/libs") - # os.mkdir("build/libs/Difficult_Rocket_rs") - # os.mkdir("build/libs/Difficult_Rocket_rs/lib") - for src, dist in files.items(): - try: - shutil.copytree(src, dist) - except Exception as e: - print(f"error: {e}") - - -if __name__ == '__main__': - show_files() - remove_un_use() - show_files() - copy_data_file() - show_files() - make_zip() diff --git a/.github/workflows/requirement.txt b/.github/workflows/requirement.txt deleted file mode 100644 index e137505..0000000 --- a/.github/workflows/requirement.txt +++ /dev/null @@ -1,5 +0,0 @@ -# for checker -# ruff >= 0.0.253 - -# for dsm upload -synology-api >= 0.5.1 \ No newline at end of file diff --git a/nuitka_build.py b/nuitka_build.py index d1559f2..0be5ab0 100644 --- a/nuitka_build.py +++ b/nuitka_build.py @@ -76,11 +76,11 @@ if __name__ == '__main__': traceback.print_exc() print('Remove Useless Files Done!') # 压缩 - # with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: - # for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): - # print(f'writing {path}') - # for file in sub_files: - # file_path = os.path.join(path, file) - # dist_zip.write(file_path) - # print('Zip Done!') + with zipfile.ZipFile(Path('./build/Difficult_Rocket.zip'), 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as dist_zip: + for path, sub_paths, sub_files in os.walk(compiler.output_path / 'DR.dist'): + print(f'writing {path}') + for file in sub_files: + file_path = os.path.join(path, file) + dist_zip.write(file_path) + print('Zip Done!') sys.exit(0) -- 2.45.2