diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70a48a6..6410548 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,14 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.11" + - name: Set up MinGW + uses: egor-tensin/setup-mingw@v2 + with: + platform: x64 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + create-symlink: true - name: Install Dependencies and Generate Bundle run: | python generate-bundle.py diff --git a/favicon.ico b/favicon.ico deleted file mode 100644 index ba4abb7..0000000 Binary files a/favicon.ico and /dev/null differ diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000..4406683 Binary files /dev/null and b/favicon.png differ diff --git a/generate-bundle.py b/generate-bundle.py index 7a28f11..221e5d3 100644 --- a/generate-bundle.py +++ b/generate-bundle.py @@ -1,29 +1,33 @@ import os import shutil +import subprocess import urllib.request import zipfile import platform if platform.system() == 'Windows': os.system("python3 -m pip install pyyaml install-jdk tqdm psutil requests pygithub " - "rtoml-0.10.0-cp311-none-win_amd64.whl pyinstaller") + "rtoml-0.10.0-cp311-none-win_amd64.whl nuitka") urllib.request.urlretrieve("https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win64.zip", "upx.zip") zip = zipfile.ZipFile("upx.zip") zip.extract("upx-4.2.4-win64/upx.exe", path=os.getcwd()) shutil.move("upx-4.2.4-win64/upx.exe", os.path.join(os.getcwd(), "upx.exe")) else: - os.system("python3 -m pip install pyyaml install-jdk tqdm psutil requests pygithub rtoml pyinstaller") - -import PyInstaller.__main__ + os.system("python3 -m pip install pyyaml install-jdk tqdm psutil requests pygithub rtoml nuitka") os.mkdir("dist") for file in os.listdir(os.path.join(os.getcwd(), "src")): filepath = os.path.join(os.getcwd(), "src", file) print(f"build {file}", flush=True) - flag = ["-F", filepath, "--optimize", "2", "-i", "favicon.ico"] - if platform.system() != 'Windows': - flag.append("--strip") - PyInstaller.__main__.run(flag) + args = ["python3", "-m", "nuitka", "--lto=yes", "--onefile", filepath, "--output-dir=dist"] + if platform.system() == 'Windows': + args.append("--windows-icon-from-ico=favicon.png") + if platform.system() == 'MacOS': + args.append("--macos-app-icon=favicon.png") + subprocess.call(args) + if platform.system() == 'Windows': + subprocess.call(["upx.exe", os.path.join(os.getcwd(), "dist", file + ".exe"), "-o", + os.path.join(os.getcwd(), "dist", file + ".exe"), "-9", "-q"]) # 傻逼 # 狗屎代碼