-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.spec
78 lines (68 loc) · 1.88 KB
/
main.spec
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
# -*- mode: python ; coding: utf-8 -*-
import shutil
import time
from pathlib import Path
from typing import TYPE_CHECKING
from zipfile import ZIP_DEFLATED, ZipFile
if TYPE_CHECKING:
from typing import cast
from PyInstaller.building.api import COLLECT, EXE, PYZ
from PyInstaller.building.build_main import Analysis
from PyInstaller.config import CONF
DISTPATH = cast(str, CONF['distpath'])
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
contents_directory='libs',
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
def zip_directory(folder_path, zip_path):
folder_path = Path(folder_path)
zip_path = Path(zip_path)
with ZipFile(zip_path, 'w', ZIP_DEFLATED, compresslevel=9) as zip_file:
for file_path in folder_path.rglob('*'):
if file_path.is_file():
arcname: Path = file_path.relative_to(folder_path)
zip_file.write(file_path, arcname)
dest_path: Path = Path(DISTPATH) / 'main'
dest_path.mkdir(parents=True, exist_ok=True)
(dest_path / 'fonts').mkdir(exist_ok=True)
shutil.copy('README.md', dest_path)
shutil.copy('draft_settings.yml', dest_path)
shutil.copy('fonts/SourceHanSans.otf', dest_path / 'fonts')
zip_directory(Path(DISTPATH) / 'main',
Path(DISTPATH) / f'Music-Box-Designer-{time.strftime('%Y-%m-%d', time.localtime())}.zip')