#!/usr/bin/env python3 """Development setup script for KYB Tech Dots.OCR.""" import subprocess import sys from pathlib import Path def run_command(cmd, description): """Run a command and handle errors.""" print(f"šŸ”„ {description}...") try: result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True) print(f"āœ… {description} completed") return True except subprocess.CalledProcessError as e: print(f"āŒ {description} failed: {e}") print(f"Error output: {e.stderr}") return False def main(): """Set up development environment.""" print("šŸš€ Setting up KYB Tech Dots.OCR development environment...") # Check if uv is installed if not run_command("uv --version", "Checking uv installation"): print("šŸ“¦ Installing uv...") if not run_command("curl -LsSf https://astral.sh/uv/install.sh | sh", "Installing uv"): print("āŒ Failed to install uv. Please install it manually from https://github.com/astral-sh/uv") sys.exit(1) # Create virtual environment if not run_command("uv venv", "Creating virtual environment"): sys.exit(1) # Install dependencies if not run_command("uv pip install -e .", "Installing package in development mode"): sys.exit(1) # Install development dependencies if not run_command("uv pip install -e .[dev]", "Installing development dependencies"): sys.exit(1) print("\nšŸŽ‰ Development environment setup complete!") print("\nšŸ“‹ Next steps:") print("1. Activate the virtual environment:") print(" source .venv/bin/activate # On Unix/macOS") print(" .venv\\Scripts\\activate # On Windows") print("\n2. Run the application:") print(" python main.py") print("\n3. Run tests:") print(" pytest") print("\n4. Run linting:") print(" ruff check .") print(" black .") if __name__ == "__main__": main()