dots-ocr-idcard / setup_dev.py
tommulder's picture
feat(api): fast FastAPI app + model loader refactor; add mock mode for tests\n\n- Add pyproject + setuptools config and console entrypoint\n- Implement enhanced field extraction + MRZ heuristics\n- Add response builder with compatibility for legacy MRZ fields\n- New preprocessing pipeline for PDFs/images\n- HF Spaces GPU: cache ENV, optional flash-attn, configurable base image\n- Add Make targets for Spaces GPU and local CPU\n- Add httpx for TestClient; tests pass in mock mode\n- Remove embedded model files and legacy app/modules
211e423
raw
history blame
2.01 kB
#!/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()