-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.py
60 lines (44 loc) · 1.17 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
import os
import sys
def buildResources():
qrcFile = os.path.join(os.path.dirname(__file__),
'designer', 'resources.qrc')
pyOutput = os.path.join('torrentbro', 'ui', 'resources.py')
os.system('pyrcc5 {file} -o {output}'.format(
file=qrcFile,
output=pyOutput
))
def buildUI():
from PyQt5.uic import compileUiDir
designDir = os.path.join(os.path.dirname(__file__), 'designer')
def uicmap(pyDir, pyFile):
rtnDir = os.path.join('torrentbro', 'ui')
rtnFile = pyFile
return rtnDir, rtnFile
compileUiDir(designDir, map=uicmap)
def _usage():
import sys
sys.stdout.write('''
Usage:
build - Build everything
build ui - Build .py files from .ui files in ui directory.
''')
if __name__ == '__main__':
import sys
args = sys.argv[1:]
cmd = args[0]
if 1 in args:
mode = args[1]
else:
mode = None
if cmd == 'build':
if mode == 'resources':
buildResources()
elif mode == 'ui':
buildUI()
else:
buildResources()
buildUI()
else:
_usage()
sys.exit(1)