algoryn/dots-ocr-idcard
0
1#!/usr/bin/env python32"""Development setup script for KYB Tech Dots.OCR."""3 4import subprocess5import sys6from pathlib import Path7 8def run_command(cmd, description):9 """Run a command and handle errors."""10 print(f"๐ {description}...")11 try:12 result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)13 print(f"โ
{description} completed")14 return True15 except subprocess.CalledProcessError as e:16 print(f"โ {description} failed: {e}")17 print(f"Error output: {e.stderr}")18 return False19 20def main():21 """Set up development environment."""22 print("๐ Setting up KYB Tech Dots.OCR development environment...")23 24 # Check if uv is installed25 if not run_command("uv --version", "Checking uv installation"):26 print("๐ฆ Installing uv...")27 if not run_command("curl -LsSf https://astral.sh/uv/install.sh | sh", "Installing uv"):28 print("โ Failed to install uv. Please install it manually from https://github.com/astral-sh/uv")29 sys.exit(1)30 31 # Create virtual environment32 if not run_command("uv venv", "Creating virtual environment"):33 sys.exit(1)34 35 # Install dependencies36 if not run_command("uv pip install -e .", "Installing package in development mode"):37 sys.exit(1)38 39 # Install development dependencies40 if not run_command("uv pip install -e .[dev]", "Installing development dependencies"):41 sys.exit(1)42 43 print("\n๐ Development environment setup complete!")44 print("\n๐ Next steps:")45 print("1. Activate the virtual environment:")46 print(" source .venv/bin/activate # On Unix/macOS")47 print(" .venv\\Scripts\\activate # On Windows")48 print("\n2. Run the application:")49 print(" python main.py")50 print("\n3. Run tests:")51 print(" pytest")52 print("\n4. Run linting:")53 print(" ruff check .")54 print(" black .")55 56if __name__ == "__main__":57 main()58 