-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
48 lines (39 loc) · 1.16 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
import os
import shutil
import sys
CURRENT_DIR = sys.path[0]
DEPENDENCIES_PATH = os.path.join(CURRENT_DIR, '.venv', 'Lib', 'site-packages')
BUILD_DIR = os.path.join(sys.path[0], 'dist')
print('Building app...')
# Delete dist dir
if os.path.exists(BUILD_DIR):
shutil.rmtree(BUILD_DIR)
# Create EXE
os.system(
f'pyinstaller --noconsole --paths {DEPENDENCIES_PATH} --name cehub ' +
f'--onefile main.py'
)
# Create dirs
os.mkdir(os.path.join(BUILD_DIR, 'resources'))
os.mkdir(os.path.join(BUILD_DIR, 'instances'))
# Copy dir and files
shutil.copytree(
os.path.join(CURRENT_DIR, 'resources', 'icons'),
os.path.join(BUILD_DIR, 'resources', 'icons'),
)
shutil.copytree(
os.path.join(CURRENT_DIR, 'resources', 'images'),
os.path.join(BUILD_DIR, 'resources', 'images'),
)
shutil.copyfile(
os.path.join(CURRENT_DIR, 'resources', 'resources.qrc'),
os.path.join(BUILD_DIR, 'resources', 'resources.qrc'),
)
shutil.copytree(
os.path.join(CURRENT_DIR, 'game'),
os.path.join(BUILD_DIR, 'game'),
)
# Make zip
shutil.make_archive('cehub', 'zip', BUILD_DIR)
shutil.move(os.path.join(CURRENT_DIR, 'cehub.zip'), BUILD_DIR)
print('Build successfully!')