-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.py
More file actions
53 lines (40 loc) · 1.42 KB
/
compile.py
File metadata and controls
53 lines (40 loc) · 1.42 KB
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
from os import walk, system, mkdir, getcwd, rename
from os.path import join, isdir
from shutil import copy2
from sys import platform
from pyshortcuts import make_shortcut
# compile main dir
system("py -m compileall -b")
dirTree: tuple = next(walk("."))
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")
# move the pyw file into the UI folder
CWD: str = getcwd()
PATH: str = join(CWD, join("UI", "Stockify.py"))
rename(PATH + "c", PATH + "w")
BINS_PATH: str = join(CWD, join("bins", "UI"))
copy2(PATH + "w", BINS_PATH)
icon_path = None
if platform == "win32":
icon_path = join(CWD, join("App_Icon", "StockifyIcon.ico"))
else:
icon_path = join(CWD, join("App_Icon", "StockifyIcon.png"))
# create app shortcut
make_shortcut(join(BINS_PATH, "Stockify.pyw"), "Stockify", startmenu=False, icon=icon_path, executable="pyw")