This repository has been archived by the owner on Apr 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
103 lines (82 loc) · 2.98 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"""
This script will build sources to executable file.
Output folder is: ./dist/
Ignore folder ./build/
Run with argument -h or --help to get more info
Script available startup args:
client - build only client. (output to ./dist/VM_Client)
server - build only server. (output to ./dist/VM_Server)
full - full VM build. (output to ./dist/*)
"""
from time import time
from sys import platform
from os import pathsep, path
from argparse import ArgumentParser
import PyInstaller.__main__
from VectorMessenger.MessengerCore.Helpers import Global as h
UPX = '--noupx'
PATH_CLIENT_PY = './VectorMessenger/client.py'
PATH_SERVER_PY = './VectorMessenger/server.py'
def build_client():
# TODO: Exclude server-side
icon = '--icon=./VectorMessenger/' + h.ICON_CLIENT_PATH[2:]
HIDDEN_IMPORT = [
'pkg_resources.py2_warn'
]
if platform != 'win32':
# Fix of tkinter import for linux builds
# ! Remove when legacy gui completely removed
HIDDEN_IMPORT.extend(['tkinter', 'PIL._tkinter_finder'])
HIDDEN_IMPORT = [('--hidden-import=' + arg) for arg in HIDDEN_IMPORT]
ADD_FILES = [
f'./VectorMessenger/data/ico{pathsep}./data/ico',
f'./LICENSE{pathsep}.',
]
ADD_FILES = [('--add-data=' + arg) for arg in ADD_FILES]
PyInstaller.__main__.run([
'--name={}'.format("VM_Client"),
*HIDDEN_IMPORT,
'--windowed',
*ADD_FILES,
icon,
UPX,
PATH_CLIENT_PY
])
def build_server():
# TODO: Exclude client-side and encryption modules
icon = '--icon=./VectorMessenger/' + h.ICON_SERVER_PATH[2:]
HIDDEN_IMPORT = [
'pkg_resources.py2_warn'
]
HIDDEN_IMPORT = [('--hidden-import=' + arg) for arg in HIDDEN_IMPORT]
ADD_FILES = (
f'./VectorMessenger/data/ico{pathsep}./data/ico',
f'./LICENSE{pathsep}.',
)
ADD_FILES = [('--add-data=' + arg) for arg in ADD_FILES]
PyInstaller.__main__.run([
'--name={}'.format("VM_Server"),
*HIDDEN_IMPORT,
'--console',
*ADD_FILES,
icon,
UPX,
PATH_SERVER_PY
])
if __name__ == "__main__":
parser = ArgumentParser(description="This utility will build Vector Messenger from source files. "
"Result will be saved to directory: ./dist/")
parser.add_argument('mode', action="store", default="full", type=str, choices=["client", "server", "full"], nargs="?",
help='Type of build. "server" - only server, "client" - only client, "full" - full build.')
args = parser.parse_args()
build_time_start = time()
if args.mode == 'client':
build_client()
elif args.mode == 'server':
build_server()
else:
build_client()
build_server()
print(f'\n--- Vector Messenger build utility in mode "{args.mode}" ---'
f'\n> Built successfully in < {round(time() - build_time_start, 2)} > sec.'
f'\n> Output to "{path.abspath("./dist/")}"')