-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.py
executable file
·63 lines (52 loc) · 1.24 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import platform
import subprocess
import sys
PYTHON_SCRIPTS_DIR = os.path.join(os.path.dirname(sys.executable), 'Scripts')
if platform.system() == 'Darwin':
import dmgbuild
def execute(cmd):
'''Excute a command'''
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
def build_macos():
'''
Build DMG for macOS platform
'''
execute([
sys.executable,
'-m', 'PyInstaller',
'--clean',
'--noconfirm',
'counter.spec',
])
dmgbuild.build_dmg(
'dist/KeyCounter.dmg',
'KeyCounter',
'dmgbuild_conf.py',
defines={}, lookForHiDPI=True
)
def build_win32():
'''
Build EXE for win32 platform
'''
execute([
os.path.join(PYTHON_SCRIPTS_DIR, 'pyinstaller'),
'--clean',
'--noconfirm',
'counter.spec',
])
def main():
if platform.system() == 'Windows':
build_win32()
elif platform.system() == 'Darwin':
build_macos()
else:
sys.stderr.write('Unsupported platform')
sys.exit(1)
if __name__ == '__main__':
main()