-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-package.py
71 lines (63 loc) · 2.24 KB
/
build-package.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import PyInstaller.__main__
import platform
import subprocess
import os
import itertools
import glob
import kikit
kikit_base = os.path.dirname(kikit.__file__)
create_dmg = False
codesign_identity = None
pyinstaller_args = []
create_dmg_args = []
if platform.system()=="Darwin":
pyinstaller_args.extend(["--add-binary", f"/Applications/KiCad/KiCad.app/Contents/Frameworks/*.dylib:."])
pyinstaller_args.extend(["-i", 'resources/icon.icns'])
subprocess.run(["security", "find-identity", "-v", "-p", "codesigning"])
codesign_identity = input("Enter the codesign identity \"Developer ID Application: XXXXXX (XXXXXXXXXX)\" (leave empty for no signing): ").strip()
if codesign_identity:
create_dmg_args.extend(["--codesign", codesign_identity])
create_dmg_args.extend(["--notarize", "notarytool-creds"])
create_dmg = True
else:
pyinstaller_args.extend(["-i", 'resources/icon.ico'])
pyinstaller_args.extend(["--add-data", f"{os.path.join(kikit_base, 'resources', 'kikit.pretty')}:kikit.pretty"])
print(pyinstaller_args)
PyInstaller.__main__.run([
'kikit-ui.py',
"--onedir",
"--noconfirm",
"--windowed",
"--add-data=resources/icon.ico:.",
*pyinstaller_args
])
if codesign_identity:
for path in itertools.chain(
glob.glob("dist/kikit-ui.app/**/*.so", recursive=True),
glob.glob("dist/kikit-ui.app/**/*.dylib", recursive=True),
glob.glob("dist/kikit-ui.app/**/Python3", recursive=True),
["dist/kikit-ui.app"],
):
print("codesign", path)
subprocess.run(["codesign",
"--sign", codesign_identity,
"--entitlements", "resources/entitlements.plist",
"--timestamp",
"--deep",
str(path),
"--force",
"--options", "runtime"
])
if create_dmg:
if os.path.exists("kikit-ui.dmg"):
os.unlink("kikit-ui.dmg")
subprocess.run([
"create-dmg",
"--volname", "KiKit-UI",
"--volicon", "resources/icon.icns",
"--app-drop-link", "0", "0",
*create_dmg_args,
"kikit-ui.dmg", "dist/kikit-ui.app"
])
if codesign_identity:
subprocess.run(["spctl", "-a", "-t", "open", "--context", "context:primary-signature", "-v", "kikit-ui.dmg"])