-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
67 lines (52 loc) · 2.14 KB
/
setup.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
import os
import shutil
import datetime
from pathlib import Path
from setuptools import setup
from distutils.dir_util import copy_tree
# Define the names of your main and background scripts
main_script = "GaziGuard.py"
background_script = "background.py"
# Function to run pyinstaller for a given script with options
def run_pyinstaller(script, options):
command = f"pyinstaller {script} {options}"
os.system(command)
# Build the main script with icon and without console
run_pyinstaller(main_script, '--icon="icon64.ico" --noconsole --noconfirm')
# Build the background script without console
# run_pyinstaller(background_script, "--noconsole --noconfirm")
# Build the background script with a different destination folder
run_pyinstaller(background_script, "--distpath dist/background_output --noconfirm")
# Get the datetime stamp
datetime_stamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
#remove last build
merged_output_folder = Path(f"dist/merged_output")
if os.path.exists(merged_output_folder):
shutil.rmtree(merged_output_folder)
# Merge the contents of the three resulting folders into one single folder
main_dist_folder = Path("dist")
background_dist_folder = Path("dist/background_output")
# merged_output_folder = Path(f"dist/merged_output_{datetime_stamp}")
# merged_output_folder = Path(f"dist/merged_output")
# Copy the main script files
copy_tree(str(main_dist_folder / main_script.split(".")[0]), str(merged_output_folder))
# Copy the background script files
copy_tree(str(background_dist_folder / background_script.split(".")[0]), str(merged_output_folder))
# Remove unnecessary files generated by pyinstaller
for file in merged_output_folder.rglob("__pycache__"):
shutil.rmtree(file)
# Copy the icon and config.ini files to the merged output folder
shutil.copy("icon64.ico", str(merged_output_folder))
# Create the setup for the merged folder
setup(
name="GaziGuard",
version="1.0.2",
packages=[],
scripts=[],
)
# Clean up the temporary folders
shutil.rmtree(main_dist_folder)
shutil.rmtree(background_dist_folder)
shutil.rmtree('background.spec')
shutil.rmtree('GaziGuard.spec')
print("Build completed successfully!")