66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
from src.constants import VERSION
|
|
|
|
load_dotenv()
|
|
|
|
print("=" * 50)
|
|
print("PREBUILD CONFIGURATION")
|
|
print("=" * 50)
|
|
|
|
# Check if running in virtual environment
|
|
project_root = Path(__file__).parent
|
|
expected_venv_path = project_root / ".venv"
|
|
current_executable = Path(sys.executable)
|
|
|
|
print(f"\nPython executable: {sys.executable}")
|
|
|
|
is_correct_venv = False
|
|
try:
|
|
current_executable.relative_to(expected_venv_path)
|
|
is_correct_venv = True
|
|
except ValueError:
|
|
is_correct_venv = False
|
|
|
|
if is_correct_venv:
|
|
print("✓ Correct environment selected for building")
|
|
else:
|
|
print("✗ Wrong environment selected")
|
|
print(f" Expected: {expected_venv_path}")
|
|
print(f" Current: {current_executable.parent.parent}")
|
|
|
|
print(f"✓ Version: {VERSION}")
|
|
|
|
env_debug = os.getenv("ENV_DEBUG", "false").lower() == "true"
|
|
console_mode = env_debug
|
|
default_spec = Path(__file__).parent.name + ".spec"
|
|
spec_filename = os.getenv("ENV_BUILD_SPEC", default_spec)
|
|
|
|
print(f"\n{'-' * 50}")
|
|
print("BUILD SETTINGS")
|
|
print(f"{'-' * 50}")
|
|
print(f"ENV_DEBUG: {env_debug}")
|
|
print(f"Console mode: {console_mode}")
|
|
print(f"Spec file: {spec_filename}")
|
|
|
|
spec_path = Path(__file__).parent / spec_filename
|
|
if spec_path.exists():
|
|
with open(spec_path, "r", encoding="utf-8") as f:
|
|
spec_content = f.read()
|
|
|
|
if f"console={not console_mode}" in spec_content:
|
|
new_spec_content = spec_content.replace(
|
|
f"console={not console_mode}",
|
|
f"console={console_mode}"
|
|
)
|
|
with open(spec_path, "w", encoding="utf-8") as f:
|
|
f.write(new_spec_content)
|
|
print(f"✓ Updated {spec_filename}: console={console_mode}")
|
|
else:
|
|
print(f"✓ {spec_filename} already configured: console={console_mode}")
|
|
else:
|
|
print(f"✗ {spec_filename} not found!")
|
|
|
|
print(f"{'-' * 50}\n") |