-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.py
42 lines (35 loc) · 1.45 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import shutil
import subprocess
import sys
import urllib.request
import zipfile
import platform
if platform.system() == 'Windows':
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"))
os.mkdir("build")
os.mkdir("dist")
def build(filepath):
args = ["python", "-m", "nuitka", "--onefile", filepath, "--assume-yes-for-downloads", "--output-dir=build"]
if platform.system() == 'Windows':
args.append("--windows-icon-from-ico=favicon.png")
args.append("--enable-plugins=upx")
args.append("--upx-binary=upx.exe")
if platform.system() == 'MacOS':
args.append("--macos-app-icon=favicon.png")
if platform.system() == 'Linux':
args.append("--linux-icon=favicon.png")
args.append("--windows-console-mode=disable")
args.append("--enable-plugin=pyside6")
subprocess.call(args)
filename = os.path.splitext(os.path.basename(filepath))[0]
for f in os.listdir(os.path.join(os.getcwd(), "build")):
if f.startswith(filename) and not os.path.isdir(os.path.join(os.getcwd(), "build", f)):
shutil.move(os.path.join(os.getcwd(), "build", f), os.path.join(os.getcwd(), "dist", f))
build("gui/main.py")
# 傻逼
# 狗屎代碼