-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.py
More file actions
35 lines (32 loc) · 1.02 KB
/
Copy pathpackage.py
File metadata and controls
35 lines (32 loc) · 1.02 KB
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
import os
import subprocess
import shutil
def build_frontend():
print("Building frontend...")
os.chdir("frontend")
subprocess.run("npm install", shell=True, check=True)
subprocess.run("npm run build", shell=True, check=True)
os.chdir("..")
def create_exe():
print("Creating EXE...")
# Bundle FastAPI app + built frontend
# We use --add-data to include the 'frontend/dist' folder
# Note: On Windows, the separator is ;
command = [
"pyinstaller",
"--noconfirm",
"--onefile",
"--console", # Set to --windowed if you don't want a console
"--add-data", "frontend/dist;frontend/dist",
"--add-data", ".env;.",
"server.py"
]
subprocess.run(" ".join(command), shell=True, check=True)
if __name__ == "__main__":
try:
if os.path.exists("frontend"):
build_frontend()
create_exe()
print("\nSuccess! Your EXE is in the 'dist' folder.")
except Exception as e:
print(f"\nError during build: {e}")