-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
58 lines (42 loc) · 1.68 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
import os
import sys
import PyInstaller.__main__
from pathlib import Path
import shutil
def build(program_path:Path, dist_path:Path, version:str):
on_windows = (os.name == 'nt')
version_file = dist_path/'VERSION.txt'
if version_file.exists():
os.remove(version_file)
with open(version_file,'w') as f:
f.write(version)
PyInstaller.__main__.run([
'./src/qr_code_stencilator/main.py',
'--onefile',
'--noconfirm',
'--nowindow',
'--name=qr_code_stencilator',
f'--distpath={dist_path.as_posix()}'
])
shutil.copy2(program_path/'paper_formats.toml', dist_path)
presets_path = program_path/'presets/'
dist_presets_path = dist_path/'presets/'
dist_presets_path.mkdir(exist_ok=True)
shutil.copy2(presets_path/'default.toml', dist_presets_path)
shutil.copy2(presets_path/'example_preset.toml', dist_presets_path)
dist_outputs_path = dist_path/'outputs/'
dist_outputs_path.mkdir(exist_ok=True)
shutil.copy2(program_path/'README.md', dist_path)
documentation_path = program_path/'documentation/'
dist_documentation_path = dist_path/'documentation/'
shutil.copytree(documentation_path,dist_documentation_path, dirs_exist_ok=True)
shutil.rmtree(dist_documentation_path/'example_gif_frames/')
if on_windows:
os.system(f'attrib +h "{version_file}"')
os.system(f'attrib +h "{dist_presets_path/"default.toml"}"')
if __name__ == "__main__":
version = sys.argv[-1]
dist_path = Path(f'./dist/qr_code_stencilator_{version}')
dist_path.mkdir(parents=True,exist_ok=True)
program_path = Path(os.getcwd())
build(program_path, dist_path, version)