Skip to content

Commit cac4013

Browse files
committed
Added improved build script
1 parent be40455 commit cac4013

2 files changed

Lines changed: 58 additions & 11 deletions

File tree

build.bat

Lines changed: 0 additions & 11 deletions
This file was deleted.

build.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from pathlib import Path
2+
import subprocess
3+
import os
4+
5+
def main():
6+
# Get the path to the current directory
7+
current_dir = Path(__file__).parent.absolute()
8+
9+
# Ask the user for the Path to the build directory
10+
repo_dir = input("Enter the path to the build directory (empty for parent folder): ")
11+
if repo_dir == "":
12+
repo_dir = Path(current_dir.parent, "Target-Analysis-build")
13+
else:
14+
repo_dir = Path(repo_dir)
15+
16+
# Clone the repository into the build directory
17+
print(f"Cloning repository into {repo_dir}...")
18+
subprocess.run(["git", "clone", "https://github.com/PicoPlanetDev/Target-Analysis", str(repo_dir)])
19+
print(f"Repository cloned into {repo_dir}")
20+
21+
# Build with pyinstaller
22+
print("Building with PyInstaller...")
23+
subprocess.run(["pyinstaller", "gui.spec"], cwd=repo_dir)
24+
print("Build complete")
25+
build_dir = Path(repo_dir, "dist", "TargetAnalysis")
26+
print(f"Binaries in {build_dir}")
27+
28+
if os.name == "nt":
29+
# Ask the user if they want to hide files
30+
hide_files = input("Hide obscure files? (y/n): ")
31+
if hide_files == "y":
32+
exclude_paths = [
33+
"README.md",
34+
"LICENSE.md",
35+
"TargetAnalysis.exe",
36+
"data",
37+
"images"
38+
]
39+
for path in build_dir.iterdir():
40+
name = Path(path).name
41+
if name not in exclude_paths:
42+
subprocess.run(["attrib", "+h", name], cwd=build_dir)
43+
print("Files hidden")
44+
45+
# Ask the user if they want to open the build directory in explorer
46+
open_explorer = input("Open build directory? (y/n): ")
47+
if open_explorer == "y":
48+
subprocess.run(["explorer", str(build_dir)])
49+
50+
# Ask the user if they want to zip the build directory
51+
zip_build = input("Zip build directory? (y/n): ")
52+
if zip_build == "y":
53+
zip_path = Path(repo_dir, "Target-Analysis.zip")
54+
subprocess.run(["7z", "a", str(zip_path), str(build_dir)])
55+
print(f"Build zipped to {zip_path}")
56+
57+
if __name__ == "__main__":
58+
main()

0 commit comments

Comments
 (0)