-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.py
50 lines (38 loc) · 1.3 KB
/
compile.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
from os import walk, system, mkdir, rename, remove
from os.path import join, isdir, exists
from shutil import copy2, move
# compile main dir
system("py -m compileall -b")
dirTree: tuple = next(walk("."))
testTree: list = [join("UnitTest", "DataBase"), join("UnitTest", "Helper"),
join("UnitTest", "Login")]
if isdir("bins") == False:
mkdir("bins")
# compile sub dirs
for itr in dirTree[1]:
system(f"cd {itr} && py -m compileall -b")
# copy all compiled (non-unit test) files into bins folder
if((itr != ".git") and (itr != "bins") and (itr != ".vscode") and
(itr != "UnitTest")):
dirName = join("bins", itr)
if isdir(dirName) == False:
mkdir(dirName)
for file in next(walk(itr))[2]:
if file[-4:] == ".pyc":
copy2(join(itr, file), dirName)
# copy main compiled files to bins folder
for itr in dirTree[2]:
if itr[-4:] == ".pyc":
if((itr != "compile.pyc") and (itr != "setup.pyc")):
copy2(itr, "bins")
# compile unit test
for itr in testTree:
system(f"cd {itr} && py -m compileall -b")
# convert the main .pyc file to a .pyw
PATH = join("UI", "Stockify.py")
FINAL_PATH = join("bins", PATH + "w")
if exists(FINAL_PATH):
remove(FINAL_PATH)
copy2(join("Dependencies", "requirements.txt"), join("bins", "Dependencies"))
rename(join("bins", PATH + "c"), FINAL_PATH)
move(FINAL_PATH, "Stockify.pyw")