Skip to content

Commit 33ca5b3

Browse files
committed
add option to build exe
1 parent bf9696d commit 33ca5b3

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Python
2+
__pycache__/
3+
*.pyc
4+
5+
# PyInstaller
6+
build/
7+
dist/
8+
*.spec
9+
10+
# IDE
11+
.vscode/
12+
.idea/
13+
14+
# Environment
15+
venv/
16+
env/

build.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import PyInstaller.__main__
2+
import os
3+
import shutil
4+
5+
# Ensure dist/build directories are clean
6+
if os.path.exists("dist"):
7+
shutil.rmtree("dist")
8+
if os.path.exists("build"):
9+
shutil.rmtree("build")
10+
11+
print("Starting build process...")
12+
13+
PyInstaller.__main__.run([
14+
'main.py',
15+
'--name=SteamLuaPatcher',
16+
'--onefile',
17+
'--noconsole',
18+
'--clean',
19+
'--collect-all=ttkbootstrap', # Important for themes
20+
'--add-data=All Games Files;All Games Files', # Format: "source;dest" (Windows)
21+
'--icon=NONE' # You could add an icon here if available
22+
])
23+
24+
print("Build complete. Executable is in 'dist' folder.")

main.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,30 @@
1616
import tkinter.ttk as ttk
1717
from tkinter import TOP, BOTTOM, LEFT, RIGHT, BOTH, X, Y, END
1818

19+
def get_resource_path(relative_path):
20+
""" Get absolute path to resource, works for dev and for PyInstaller """
21+
try:
22+
# PyInstaller creates a temp folder and stores path in _MEIPASS
23+
base_path = sys._MEIPASS
24+
except Exception:
25+
base_path = os.path.dirname(os.path.abspath(__file__))
26+
27+
return os.path.join(base_path, relative_path)
28+
1929
# Constants
20-
LUA_FILES_DIR = r"d:\antigravity\luapatcher\All Games Files"
30+
# If running as source, we might need to point to the folder specifically if it's not in the same dir as main.py
31+
# But for now, let's assume if it's source, it's relative or absolute.
32+
# The user's original path was absolute: r"d:\antigravity\luapatcher\All Games Files"
33+
# We need to switch logic: if bundled, use embedded; if source, use original known path OR relative.
34+
35+
if getattr(sys, 'frozen', False):
36+
# Running as compiled exe
37+
LUA_FILES_DIR = get_resource_path("All Games Files")
38+
else:
39+
# Running as script
40+
# We prefer the specific development path provided earlier, or relative if portable
41+
LUA_FILES_DIR = r"d:\antigravity\luapatcher\All Games Files"
42+
2143
STEAM_PLUGIN_DIR = r"C:\Program Files (x86)\Steam\config\stplug-in"
2244
STEAM_EXE_PATH = r"C:\Program Files (x86)\Steam\Steam.exe"
2345

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests
22
ttkbootstrap
3+
pyinstaller

0 commit comments

Comments
 (0)