forked from EdibleBug/WoWS-GameParams
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_exe.py
29 lines (26 loc) · 1.13 KB
/
build_exe.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
import os
import shutil
import zipfile
def _resetDir(dirname: str):
"""
Removes a directory if it exists and creates a new one.
"""
if os.path.exists(dirname):
shutil.rmtree(dirname)
os.mkdir(dirname)
if __name__ == '__main__':
os.system(r'pyinstaller --onefile .\run.py --add-data .\src\wowsunpack\wowsunpack.exe;.')
_resetDir('dist\WoWsUnpack')
# shutil.copy('wowsunpack.exe', 'dist\WoWsUnpack\wowsunpack.exe')
# copy LICENSE and README.md as well
shutil.copy('LICENSE', 'dist\WoWsUnpack\LICENSE.txt')
shutil.copy('README.md', 'dist\WoWsUnpack\README.txt')
shutil.copy('使用说明.md', 'dist\WoWsUnpack\使用说明.txt')
shutil.move('dist/run.exe', 'dist/WoWsUnpack/unpack.exe')
# create zip file from WoWsUnpack folder with compression
with zipfile.ZipFile('dist/WoWsUnpack.zip', 'w', zipfile.ZIP_DEFLATED) as zip_file:
for root, dirs, files in os.walk('dist/WoWsUnpack'):
for file in files:
# remove dist/ folder
zip_file.write(os.path.join(root, file), arcname=os.path.join(root[len('dist/'):], file))
print('complete')