Skip to content

Commit

Permalink
Add development mode support to build_app function and modify app.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-marquez committed Mar 6, 2025
1 parent 512bb31 commit 051aa08
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
40 changes: 35 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,47 @@ def clean():
return False


def build_app(version=None):
def build_app(version=None, dev=False):
"""Build the VLC Discord RP application executable"""
print("Building VLC Discord Rich Presence application...")

# Update version_info.txt if version is provided
if version:
update_version_info(version)

# Modify app.spec for dev mode if needed
spec_file_path = os.path.join("spec", "app.spec")
if dev:
print("Development mode: Building with console window...")
# Read the spec file
with open(spec_file_path, "r") as f:
spec_content = f.read()

# Backup original spec file
with open(f"{spec_file_path}.bak", "w") as f:
f.write(spec_content)

# Replace console=False with console=True
spec_content = spec_content.replace("console=False", "console=True")

# Write modified spec file
with open(spec_file_path, "w") as f:
f.write(spec_content)

# Run PyInstaller for the main application
try:
subprocess.run(["pyinstaller", "--clean", "spec/app.spec"], check=True)
print("Application build complete!")
return os.path.exists(os.path.join("dist", "VLC Discord Presence.exe"))
success = os.path.exists(os.path.join("dist", "VLC Discord Presence.exe"))
except subprocess.CalledProcessError:
print("Application build failed!")
return False
success = False

# Restore original spec file if modified
if dev and os.path.exists(f"{spec_file_path}.bak"):
shutil.move(f"{spec_file_path}.bak", spec_file_path)

return success


def update_version_info(version):
Expand Down Expand Up @@ -180,13 +205,18 @@ def package():
"--version",
help="Version number to update in version_info.txt",
)
parser.add_argument(
"--dev",
action="store_true",
help="Build in development mode with console window enabled",
)

args = parser.parse_args()

if args.command == "clean":
clean()
elif args.command == "build":
build_app(version=args.version)
build_app(version=args.version, dev=args.dev)
elif args.command == "installer":
build_installer()
elif args.command == "package":
Expand All @@ -196,7 +226,7 @@ def package():
elif args.command == "all":
if not clean():
exit(1)
if not build_app(args.version):
if not build_app(args.version, dev=args.dev):
exit(1)
if not build_installer():
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion spec/app.spec
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exe = EXE(
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
Expand Down

0 comments on commit 051aa08

Please sign in to comment.