Skip to content

Commit

Permalink
启用nuitka
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingfengdev committed Jun 28, 2024
1 parent f87aacb commit 2302f56
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
create-symlink: true
- name: Install Dependencies and Generate Bundle
run: |
python generate-bundle.py
Expand Down
Binary file removed favicon.ico
Binary file not shown.
Binary file added favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions generate-bundle.py
Original file line number Diff line number Diff line change
@@ -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"])
# 傻逼
# 狗屎代碼

0 comments on commit 2302f56

Please sign in to comment.