123 lines
3.5 KiB
Python
123 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
PunimTag CLI Setup Script
|
|
Simple setup for the minimal photo tagger
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def check_python_version():
|
|
"""Check if Python version is compatible"""
|
|
if sys.version_info < (3, 7):
|
|
print("❌ Python 3.7+ is required")
|
|
return False
|
|
print(f"✅ Python {sys.version_info.major}.{sys.version_info.minor} detected")
|
|
return True
|
|
|
|
|
|
def install_requirements():
|
|
"""Install Python requirements"""
|
|
requirements_file = Path("requirements.txt")
|
|
|
|
if not requirements_file.exists():
|
|
print("❌ requirements.txt not found!")
|
|
return False
|
|
|
|
print("📦 Installing Python dependencies...")
|
|
try:
|
|
subprocess.run([
|
|
sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'
|
|
], check=True)
|
|
print("✅ Dependencies installed successfully")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ Failed to install dependencies: {e}")
|
|
return False
|
|
|
|
|
|
def create_directories():
|
|
"""Create necessary directories"""
|
|
directories = ['data', 'logs']
|
|
|
|
for directory in directories:
|
|
Path(directory).mkdir(exist_ok=True)
|
|
print(f"✅ Created directory: {directory}")
|
|
|
|
|
|
def test_installation():
|
|
"""Test if face recognition works"""
|
|
print("🧪 Testing face recognition installation...")
|
|
try:
|
|
import face_recognition
|
|
import numpy as np
|
|
from PIL import Image
|
|
print("✅ All required modules imported successfully")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"❌ Import error: {e}")
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""Main setup function"""
|
|
print("🚀 PunimTag CLI Setup")
|
|
print("=" * 40)
|
|
|
|
# Check Python version
|
|
if not check_python_version():
|
|
return 1
|
|
|
|
# Check if we're in a virtual environment (recommended)
|
|
if sys.prefix == sys.base_prefix:
|
|
print("⚠️ Not in a virtual environment!")
|
|
print(" Recommended: python -m venv venv && source venv/bin/activate")
|
|
response = input(" Continue anyway? (y/N): ").strip().lower()
|
|
if response != 'y':
|
|
print("Setup cancelled. Create a virtual environment first.")
|
|
return 1
|
|
else:
|
|
print("✅ Virtual environment detected")
|
|
|
|
print()
|
|
|
|
# Create directories
|
|
print("📁 Creating directories...")
|
|
create_directories()
|
|
print()
|
|
|
|
# Install requirements
|
|
if not install_requirements():
|
|
return 1
|
|
print()
|
|
|
|
# Test installation
|
|
if not test_installation():
|
|
print("⚠️ Installation test failed. You may need to install additional dependencies.")
|
|
print(" For Ubuntu/Debian: sudo apt-get install build-essential cmake")
|
|
print(" For macOS: brew install cmake")
|
|
return 1
|
|
print()
|
|
|
|
print("✅ Setup complete!")
|
|
print()
|
|
print("🎯 Quick Start:")
|
|
print(" 1. Add photos: python3 photo_tagger.py scan /path/to/photos")
|
|
print(" 2. Process faces: python3 photo_tagger.py process")
|
|
print(" 3. Identify faces: python3 photo_tagger.py identify")
|
|
print(" 4. View stats: python3 photo_tagger.py stats")
|
|
print()
|
|
print("📖 For help: python3 photo_tagger.py --help")
|
|
print()
|
|
print("⚠️ IMPORTANT: Always activate virtual environment first!")
|
|
print(" source venv/bin/activate")
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|