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..310108f 100644 --- a/.github/workflows/nuitka.yml +++ b/.github/workflows/nuitka.yml @@ -10,12 +10,16 @@ on: - "configs/**" # 配置修改 - "libs/pyglet/**" # pyglet 修改 - ".github/workflows/**" # workflow 修改 + - "nuitka_build.py" # 构建脚本修改 + - "requirements*" # 依赖修改 pull_request: paths: - "Difficult_Rocket/**" # 本体修改 - "configs/**" # 配置修改 - "libs/pyglet/**" # pyglet 修改 - ".github/workflows/**" # workflow 修改 + - "nuitka_build.py" # 构建脚本修改 + - "requirements*" # 依赖修改 workflow_dispatch: # 主任务 @@ -39,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 @@ -91,86 +81,35 @@ 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' }} + # 获取短 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: - 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/main.zip + 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 23ed768..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 zipfile -import shutil - -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/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..9f99b9c 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) @@ -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/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/docs/README-en.md b/docs/README-en.md index 9f83299..acedd92 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) @@ -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/docs/src/change_log/build_file.md b/docs/src/change_log/build_file.md new file mode 100644 index 0000000..7f6c138 --- /dev/null +++ b/docs/src/change_log/build_file.md @@ -0,0 +1,17 @@ + +# DR 构建 更新日志 + +- 最新构建版本号 + - build_version: 1.3.0.0 + +## 20230609 build 2.0.0.0 + +### Breaking Change + +- 将构建脚本生成方式改为通过 `libs/utils/nuitka.py` 生成 +- + +## 202306 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/libs/utils/nuitka.py b/libs/utils/nuitka.py index f72ad91..eddd864 100644 --- a/libs/utils/nuitka.py +++ b/libs/utils/nuitka.py @@ -13,29 +13,41 @@ 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") + 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 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 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'] - 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] = [] + + follow_import: List[str] = ['pyglet'] + no_follow_import: List[str] = ['objprint', 'pillow', 'PIL', 'cffi', 'pydoc', 'numpy'] + + 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: # 非 windows 平台不使用 msvc @@ -65,7 +77,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': @@ -77,20 +89,37 @@ 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()}") 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] + + 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] + + 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/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock index f4569ed..1c583e2 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.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" dependencies = [ "cfg-if", "crossbeam-utils", @@ -145,21 +145,21 @@ checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "libc" -version = "0.2.146" +version = "0.2.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ "autocfg", "scopeguard", @@ -167,17 +167,19 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] [[package]] name = "matrixmultiply" -version = "0.3.7" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" dependencies = [ - "autocfg", "rawpointer", ] @@ -270,9 +272,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "optional" @@ -292,22 +294,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-sys", ] [[package]] name = "parry2d-f64" -version = "0.13.4" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f612055f319eb83e67841fdf00248eee26045a1759b5d94fa9c6ecce7c1e78d" +checksum = "4a1bf555d44a3be6c6b6acdea1614af50b12987b4b9651c812d3219e8136c336" dependencies = [ "approx", "arrayvec", @@ -332,9 +334,9 @@ checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -401,9 +403,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -437,9 +439,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -458,9 +460,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "safe_arch" -version = "0.7.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" +checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" dependencies = [ "bytemuck", ] @@ -473,9 +475,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] @@ -494,13 +496,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.13", ] [[package]] @@ -533,9 +535,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "spade" -version = "2.2.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e65803986868d2372c582007c39ba89936a36ea5f236bf7a7728dc258f04f9" +checksum = "1190e0e8f4eb17fc3dbb2d20e1142676e56aaac3daede39f64a3302d687b80f3" dependencies = [ "num-traits", "optional", @@ -556,9 +558,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.18" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" dependencies = [ "proc-macro2", "quote", @@ -567,9 +569,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] name = "thiserror" @@ -588,7 +590,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.13", ] [[package]] @@ -599,9 +601,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unindent" @@ -617,19 +619,28 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "wide" -version = "0.7.10" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" +checksum = "b689b6c49d6549434bf944e6b0f39238cf63693cb7a147e9d887507fffa3b223" dependencies = [ "bytemuck", "safe_arch", ] [[package]] -name = "windows-targets" -version = "0.48.0" +name = "windows-sys" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -642,48 +653,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "xml-rs" -version = "0.8.14" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52839dc911083a8ef63efa4d039d1f58b5e409f923e44c80828f206f66e5541c" +checksum = "dc95a04ea24f543cd9be5aab44f963fa35589c99e18415c38fb2b17e133bf8d2" diff --git a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml index c787117..b563714 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.164" +version = "1.0.163" features = ["derive"] [dependencies.xml-rs] -version = "0.8.14" +version = "0.8.10" [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 a362c4d..1030175 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/setup.py +++ b/mods/dr_game/Difficult_Rocket_rs/src/setup.py @@ -6,18 +6,17 @@ import sys import shutil from setuptools import setup -from setuptools_rust import Binding, RustExtension, Strip +from setuptools_rust import Binding, RustExtension package_path = 'Difficult_Rocket_rs' setup( name='Difficult_Rocket_rs', - version="0.2.10.1", + version="0.2.9.3", author='shenjackyuanjie', author_email='3695888@qq.com', rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs", - binding=Binding.PyO3, - strip=Strip.All)], + binding=Binding.PyO3)], zip_safe=False, ) 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/nuitka_build.py b/nuitka_build.py new file mode 100644 index 0000000..0be5ab0 --- /dev/null +++ b/nuitka_build.py @@ -0,0 +1,86 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- + +import os +import sys +import time +import shutil +import zipfile +import traceback +import subprocess + +from pathlib import Path + +from libs.utils import nuitka + +if __name__ == '__main__': + compiler = nuitka.CompilerHelper() + + # 修改 python 执行文件 为 运行时的 python + compiler.python_cmd = sys.executable + + # 检测 --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') + compiler.python_cmd = 'python' + + # 检测 --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) 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: + do_compile = 'y' + elif is_github: + do_compile = 'y' + else: + do_compile = 'n' + + if do_compile == 'y': + # 编译 + time.sleep(1) # 等待 1s + 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) / 1000_000_000} s)') + if is_github: + # 去除无用字体文件 + try: + 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!') + # 压缩 + 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) 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 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"} 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