-
Notifications
You must be signed in to change notification settings - Fork 37
/
pack.py
43 lines (41 loc) · 1.86 KB
/
pack.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
import os
import pathlib
import shutil
import subprocess
import time
import zipfile
os.chdir('pack_assets')
os.system(
r'..\venv310\Scripts\pyinstaller --onefile --uac-admin ' +
'--collect-all=nylib ' +
'--collect-all=win32com ' +
'--icon=sage.ico ' +
'..\main.py'
)
os.system(
r'..\venv310\Scripts\pyinstaller --onefile --uac-admin ' +
'--collect-all=nylib ' +
'--collect-all=win32com ' +
'--icon=sage.ico ' +
'..\main_cn.py'
)
os.chdir('../')
shutil.copy(r'pack_assets/dist/main.exe', 'FFDraw.exe')
p = pathlib.Path(time.strftime("pack_assets/release/%Y_%m_%d_%H_%M_%S"))
p.mkdir(parents=True)
with zipfile.ZipFile(p / 'ffd_cn_release.zip', 'w') as zf_cn, zipfile.ZipFile(p / 'ffd_release.zip', 'w') as zf:
zf_cn.write(r'pack_assets/dist/main_cn.exe', 'FFDraw/FFDraw.exe', compresslevel=9, compress_type=zipfile.ZIP_DEFLATED)
zf.write(r'pack_assets/dist/main.exe', 'FFDraw/FFDraw.exe', compresslevel=9, compress_type=zipfile.ZIP_DEFLATED)
for f in subprocess.check_output("git ls-files", shell=True).decode('utf-8').splitlines():
zf.write(f, 'FFDraw/' + f, compresslevel=9, compress_type=zipfile.ZIP_DEFLATED)
zf_cn.write(f, 'FFDraw/' + f, compresslevel=9, compress_type=zipfile.ZIP_DEFLATED)
cwd = os.getcwd()
for _line in subprocess.check_output("git config --file .gitmodules --get-regexp path", shell=True).decode('utf-8').splitlines():
_, path, *__ = _line.split(' ')
os.chdir(os.path.join(cwd, path))
for _f in subprocess.check_output("git ls-files", shell=True).decode('utf-8').splitlines():
f = os.path.join(cwd, path, _f)
zf.write(f, 'FFDraw/' + path + '/' + _f, compresslevel=9, compress_type=zipfile.ZIP_DEFLATED)
zf_cn.write(f, 'FFDraw/' + path + '/' + _f, compresslevel=9, compress_type=zipfile.ZIP_DEFLATED)
os.chdir(cwd)
print(os.path.abspath(p))