Add brand-specific update channel and environment configuration
- Updated `brand_config.py` to include `WEBDROP_UPDATE_CHANNEL` in the environment variables. - Enhanced `build_macos.sh` to create a bundled `.env` file with brand-specific defaults, including the update channel. - Implemented a method in `build_windows.py` to create a bundled `.env` file for Windows builds, incorporating brand-specific runtime defaults. - Modified `config.py` to ensure the application can locate the `.env` file in various installation scenarios. - Added unit tests in `test_config.py` to verify the loading of the bootstrap `.env` from the PyInstaller runtime directory. - Generated new WiX object and script files for the Windows installer, including application shortcuts and registry entries.
This commit is contained in:
parent
de6e9838e5
commit
eab1009d8c
9 changed files with 3083 additions and 2886 deletions
|
|
@ -38,6 +38,8 @@ import argparse
|
|||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
from dotenv import dotenv_values
|
||||
|
||||
# Import shared version utilities
|
||||
from brand_config import load_brand_config
|
||||
from sync_version import get_current_version, do_sync_version
|
||||
|
|
@ -95,6 +97,44 @@ class WindowsBuilder:
|
|||
shutil.rmtree(path)
|
||||
print(f" Removed {path}")
|
||||
|
||||
@staticmethod
|
||||
def _format_env_value(value: str) -> str:
|
||||
"""Format env values safely for .env files."""
|
||||
if any(ch in value for ch in [" ", "#", '"', "'", "\t"]):
|
||||
escaped = value.replace("\\", "\\\\").replace('"', '\\"')
|
||||
return f'"{escaped}"'
|
||||
return value
|
||||
|
||||
def _create_bundled_env_file(self) -> Path:
|
||||
"""Create a bundled .env file with brand-specific runtime defaults."""
|
||||
values = dotenv_values(self.env_file)
|
||||
overrides = {
|
||||
"APP_NAME": self.brand.display_name,
|
||||
"BRAND_ID": self.brand.brand_id,
|
||||
"APP_CONFIG_DIR_NAME": self.brand.config_dir_name,
|
||||
"UPDATE_CHANNEL": self.brand.update_channel,
|
||||
}
|
||||
|
||||
output_env = self.temp_dir / ".env"
|
||||
output_env.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
lines: list[str] = []
|
||||
for key, raw_value in values.items():
|
||||
if key in overrides:
|
||||
continue
|
||||
if raw_value is None:
|
||||
lines.append(key)
|
||||
else:
|
||||
lines.append(f"{key}={self._format_env_value(str(raw_value))}")
|
||||
|
||||
lines.append("")
|
||||
lines.append("# Brand-specific defaults added during packaging")
|
||||
for key, value in overrides.items():
|
||||
lines.append(f"{key}={self._format_env_value(value)}")
|
||||
|
||||
output_env.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
return output_env
|
||||
|
||||
def build_executable(self) -> bool:
|
||||
"""Build executable using PyInstaller."""
|
||||
print("\n🔨 Building Windows executable with PyInstaller...")
|
||||
|
|
@ -119,7 +159,7 @@ class WindowsBuilder:
|
|||
|
||||
# Set environment variable for spec file to use
|
||||
env = os.environ.copy()
|
||||
env["WEBDROP_ENV_FILE"] = str(self.env_file)
|
||||
env["WEBDROP_ENV_FILE"] = str(self._create_bundled_env_file())
|
||||
env["WEBDROP_BRAND_ID"] = self.brand.brand_id
|
||||
env["WEBDROP_APP_DISPLAY_NAME"] = self.brand.display_name
|
||||
env["WEBDROP_ASSET_PREFIX"] = self.brand.asset_prefix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue