-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
46 lines (36 loc) · 1.25 KB
/
install.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
import os
import shutil
if __name__ == "__main__":
# set these params
py_paths = ["GUI", "HTTPServer"]
main_py_name = "light_chat"
data_path = "data"
python_path = "D:/Programs/Work/anaconda3/envs/py38/Lib/site-packages"
# install
def get_py_files(folder_path):
py_files = []
for p in os.listdir(folder_path):
path = os.path.join(folder_path, p)
if os.path.isdir(path):
py_files += get_py_files(path)
elif os.path.isfile(path) and p.endswith(".py"):
py_files += [path]
return py_files
py_files = [main_py_name + ".py"]
for py_path in py_paths:
py_files += get_py_files(py_path)
# generate cmd
cmd = "pyinstaller -y -w "
cmd += " -i " + data_path + "/images/icon.ico "
for py_file in py_files:
cmd += f"{py_file} "
cmd += " -p " + python_path
print(cmd)
os.system(cmd)
source_path = os.path.abspath(data_path)
target_path = os.path.abspath(os.path.join(".", "dist", main_py_name, data_path))
os.makedirs(target_path, exist_ok=True)
if os.path.exists(source_path):
shutil.rmtree(target_path)
shutil.copytree(source_path, target_path)
print('copy data folder finished!')