-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
executable file
·76 lines (62 loc) · 2.34 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
import os
import sys
import distutils.dir_util
import distutils.file_util
from utils import versioning, directory_utils, archive
erotes_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
os.chdir(erotes_dir)
options = sys.argv[1:]
if len(options) < 1:
print("Building in regular mode...")
mode = "regular"
elif "--release" in options:
print("Building in release mode...")
mode = "release"
else:
print("Unknown option!")
sys.exit(0)
release_version = "1.2"
build_version = versioning.Version("version")
build_version.generate_version(release_version)
pyinstaller_executable = "pyinstaller"
pyinstaller_work_path = "./pyinstaller/build"
pyinstaller_dist_path = "./pyinstaller/dist"
spec_file = "erotes.spec"
pyinstaller_build_command = (
"%s "
"--workpath=\"%s\" "
"--distpath=\"%s\" "
"%s"
) % (
pyinstaller_executable,
pyinstaller_work_path,
pyinstaller_dist_path,
spec_file
)
exe_path = "pyinstaller/dist/erotes"
distributable_path = "dist"
single_files = ["config.json"]
folders = ["templates"]
print("Building executable with pyinstaller...")
print(pyinstaller_build_command)
os.system(pyinstaller_build_command)
print("Creating distributable folder...")
distributable_folder = directory_utils.Folder(distributable_path)
distributable_folder.create()
print("Copying project executable...")
distutils.file_util.copy_file(exe_path, distributable_path)
print("Copying non-source files...")
for each in single_files:
distutils.file_util.copy_file(each, distributable_path)
for each in folders:
destination_folder = "%s/%s" % (distributable_path, each)
distutils.dir_util.copy_tree(each, destination_folder)
if mode == "release":
print("Packaging distributable...")
os.chdir(distributable_path)
l = os.listdir(".")
linux_dist_package_name = "%s/erotes-linux-%s.tar.gz" % (erotes_dir,
build_version.number)
linux_dist_package = archive.Archive(linux_dist_package_name)
linux_dist_package.package_files(l, "ustar", "gzip")
print("Done.")