- **Migration to uv package manager**: Replace pip/requirements with modern pyproject.toml - Add pyproject.toml with complete dependency management - Update all scripts and Makefile to use uv commands - Maintain backward compatibility with existing workflows - **PostgreSQL integration and migration tools**: - Enhanced config.py with automatic password URL encoding - Complete PostgreSQL setup scripts and documentation - High-performance SQLite to PostgreSQL migration tool (91x speed improvement) - Support for both connection strings and individual components - **Executable distribution system**: - PyInstaller integration for standalone .exe creation - Automated build scripts with batch file generation - Complete packaging system for end-user distribution - **Enhanced data management**: - Fix --fill-gaps command with proper method implementation - Add gap detection and historical data backfill capabilities - Implement data update functionality for existing records - Add comprehensive database adapter methods - **Developer experience improvements**: - Password encoding tools for special characters - Interactive setup wizards for PostgreSQL configuration - Comprehensive documentation and migration guides - Automated testing and validation tools 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
107 lines
2.9 KiB
Python
107 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple build script for standalone executable
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
print("Building Ping River Monitor Executable")
|
|
print("=" * 50)
|
|
|
|
# Check if PyInstaller is installed
|
|
try:
|
|
import PyInstaller
|
|
print("[OK] PyInstaller available")
|
|
except ImportError:
|
|
print("[INFO] Installing PyInstaller...")
|
|
os.system("uv add --dev pyinstaller")
|
|
|
|
# Clean previous builds
|
|
if os.path.exists('dist'):
|
|
shutil.rmtree('dist')
|
|
print("[CLEAN] Removed old dist directory")
|
|
if os.path.exists('build'):
|
|
shutil.rmtree('build')
|
|
print("[CLEAN] Removed old build directory")
|
|
|
|
# Build command with all necessary options
|
|
cmd = [
|
|
"uv", "run", "pyinstaller",
|
|
"--onefile",
|
|
"--console",
|
|
"--name=ping-river-monitor",
|
|
"--add-data=.env;.",
|
|
"--add-data=sql;sql",
|
|
"--add-data=README.md;.",
|
|
"--add-data=POSTGRESQL_SETUP.md;.",
|
|
"--add-data=SQLITE_MIGRATION.md;.",
|
|
"--hidden-import=psycopg2",
|
|
"--hidden-import=sqlalchemy.dialects.postgresql",
|
|
"--hidden-import=sqlalchemy.dialects.sqlite",
|
|
"--hidden-import=dotenv",
|
|
"--hidden-import=pydantic",
|
|
"--hidden-import=fastapi",
|
|
"--hidden-import=uvicorn",
|
|
"--hidden-import=schedule",
|
|
"--hidden-import=pandas",
|
|
"--clean",
|
|
"--noconfirm",
|
|
"run.py"
|
|
]
|
|
|
|
print("[BUILD] Running PyInstaller...")
|
|
print("[CMD] " + " ".join(cmd))
|
|
|
|
result = os.system(" ".join(cmd))
|
|
|
|
if result == 0:
|
|
print("[SUCCESS] Executable built successfully!")
|
|
|
|
# Copy .env file to dist if it exists
|
|
if os.path.exists('.env') and os.path.exists('dist'):
|
|
shutil.copy2('.env', 'dist/.env')
|
|
print("[COPY] .env file copied to dist/")
|
|
|
|
# Create batch files for easy usage
|
|
batch_files = {
|
|
'start.bat': '''@echo off
|
|
echo Starting Ping River Monitor...
|
|
ping-river-monitor.exe
|
|
pause
|
|
''',
|
|
'start-api.bat': '''@echo off
|
|
echo Starting Web API...
|
|
ping-river-monitor.exe --web-api
|
|
pause
|
|
''',
|
|
'test.bat': '''@echo off
|
|
echo Running test...
|
|
ping-river-monitor.exe --test
|
|
pause
|
|
'''
|
|
}
|
|
|
|
for filename, content in batch_files.items():
|
|
if os.path.exists('dist'):
|
|
with open(f'dist/{filename}', 'w') as f:
|
|
f.write(content)
|
|
print(f"[CREATE] {filename}")
|
|
|
|
print("\n" + "=" * 50)
|
|
print("BUILD COMPLETE!")
|
|
print(f"Executable: dist/ping-river-monitor.exe")
|
|
print("Batch files: start.bat, start-api.bat, test.bat")
|
|
print("Don't forget to edit .env file before using!")
|
|
|
|
return True
|
|
else:
|
|
print("[ERROR] Build failed!")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
sys.exit(0 if success else 1) |