From 445eb9391f661b6fb6fad001cb492dc6c2a03d07 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 18:24:24 +0800 Subject: [PATCH] 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)