-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
99 lines (92 loc) · 3.61 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
import os
import shutil
import platform
from pathlib import Path
from typing import Dict, List
if platform.system() == "Windows":
ds = ";"
elif platform.system() == "Linux":
ds = ":"
else:
raise RuntimeError("Your operating system is not supported.")
LOCALDIR = os.getcwd()
TRASH_FILES = [ "build", "SeaPlayer.spec" ]
DATA = {
# * 1) Main Files
"seaplayer": "seaplayer/",
"seaplayer/__init__.py": "seaplayer/",
"seaplayer/__main__.py": "seaplayer/",
"seaplayer/functions.py": "seaplayer/",
"seaplayer/seaplayer.py": "seaplayer/",
"seaplayer/config.py": "seaplayer/",
"seaplayer/exceptions.py": "seaplayer/",
"seaplayer/codeсbase.py": "seaplayer/",
"seaplayer/units.py": "seaplayer/",
# * 1.1) Objects
"seaplayer/objects": "seaplayer/objects/",
"seaplayer/objects/__init__.py": "seaplayer/objects/",
"seaplayer/objects/Configurate.py": "seaplayer/objects/",
"seaplayer/objects/Image.py": "seaplayer/objects/",
"seaplayer/objects/Input.py": "seaplayer/objects/",
"seaplayer/objects/Log.py": "seaplayer/objects/",
"seaplayer/objects/MusicList.py": "seaplayer/objects/",
"seaplayer/objects/Notification.py": "seaplayer/objects/",
"seaplayer/objects/ProgressBar.py": "seaplayer/objects/",
"seaplayer/objects/DataOptions.py": "seaplayer/objects/",
# * 1.2) Types
"seaplayer/types": "seaplayer/types/",
"seaplayer/types/__init__.py": "seaplayer/types/",
"seaplayer/types/Convert.py": "seaplayer/types/",
"seaplayer/types/MusicList.py": "seaplayer/types/",
"seaplayer/types/Cache.py": "seaplayer/types/",
# * 1.3) Codecs
"seaplayer/codecs": "seaplayer/codecs/",
"seaplayer/codecs/__init__.py": "seaplayer/codecs/",
"seaplayer/codecs/Any.py": "seaplayer/codecs/",
"seaplayer/codecs/AnySound.py": "seaplayer/codecs/",
"seaplayer/codecs/MIDI.py": "seaplayer/codecs/",
"seaplayer/codecs/MP3.py": "seaplayer/codecs/",
"seaplayer/codecs/OGG.py": "seaplayer/codecs/",
"seaplayer/codecs/WAV.py": "seaplayer/codecs/",
"seaplayer/codecs/FLAC.py": "seaplayer/codecs/",
"seaplayer/codecs/URLS.py": "seaplayer/codecs/",
# * 1.4) Screens
"seaplayer/screens": "seaplayer/screens/",
"seaplayer/screens/__init__.py": "seaplayer/screens/",
"seaplayer/screens/Configurate.py": "seaplayer/screens/",
"seaplayer/screens/Unknown.py": "seaplayer/screens/",
# * 2) Modules Files
"seaplayer/modules": "seaplayer/modules/",
"seaplayer/modules/__init__.py": "seaplayer/modules/",
"seaplayer/modules/colorizer.py": "seaplayer/modules/",
# * 3) CSS Files
"seaplayer/css": "seaplayer/css/",
"seaplayer/css/seaplayer.css": "seaplayer/css/",
"seaplayer/css/configurate.css": "seaplayer/css/",
"seaplayer/css/unknown.css": "seaplayer/css/",
# * 4) Assets Files
"seaplayer/assets": "seaplayer/assets/",
"seaplayer/assets/image-not-found.png": "seaplayer/assets/"
}
def localize(path: str) -> str:
return os.path.join(LOCALDIR, path.replace('/', os.sep).replace('\\', os.sep))
def add_datas(data: Dict[str, str]) -> List[str]:
return [f"--add-data \"{localize(path)}{ds}{data[path]}\"" for path in data]
COMMAND_LINE = [
"pyinstaller", "--noconfirm", "--console", "--clean", "--onefile",
f"--icon \"{localize('icons/icon.ico')}\"",
*add_datas(DATA),
f"\"{localize('SeaPlayer.py')}\""
]
COMMAND = " ".join(COMMAND_LINE)
print(COMMAND, end="\n\n")
os.system(COMMAND)
for i in TRASH_FILES:
path = Path(localize(i))
try:
if path.is_dir():
shutil.rmtree(path.name, ignore_errors=True)
else:
os.remove(path.name)
except:
pass