#!/usr/bin/env python3
"""
Quick setup script for Xeepy development environment.
"""
import subprocess
import sys
from pathlib import Path
def run_command(command: str, description: str):
"""Run a shell command."""
print(f"\n{'='*60}")
print(f"π¦ {description}")
print(f"{'='*60}")
result = subprocess.run(command, shell=True)
if result.returncode != 0:
print(f"β Failed: {description}")
sys.exit(1)
print(f"β
Success: {description}")
def main():
"""Run setup tasks."""
print("""
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β π Xeepy Development Environment Setup β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
""")
# Check Python version
if sys.version_info < (3, 8):
print("β Python 3.8 or higher is required")
sys.exit(1)
print(f"β
Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
# Install package in development mode with all dependencies
run_command(
"pip install -e '.[all,dev,test,docs]'",
"Installing Xeepy with all dependencies"
)
# Create example config
example_config = Path("xeepy.example.yml")
config = Path("xeepy.yml")
if not config.exists() and example_config.exists():
import shutil
shutil.copy(example_config, config)
print(f"β
Created {config} from example")
# Install pre-commit hooks
try:
run_command("pre-commit install", "Installing pre-commit hooks")
except Exception:
print("β οΈ Pre-commit hooks not installed (optional)")
# Run tests
print("\n" + "="*60)
print("π§ͺ Running tests to verify installation")
print("="*60)
try:
subprocess.run(["pytest", "--version"], check=True)
subprocess.run(["pytest", "-v", "--tb=short"], check=False)
except Exception:
print("β οΈ Tests not run (pytest may not be installed)")
# Success message
print("""
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β β
Setup Complete! β
β β
β Quick Start: β
β β’ xeepy --help - CLI help β
β β’ xeepy-api - Start API server β
β β’ xeepy scrape profile USER - Scrape a profile β
β β’ python -m pytest - Run tests β
β β
β Documentation: β
β β’ README.md - Getting started β
β β’ xeepy.yml - Configuration β
β β’ http://localhost:8000/docs - API docs (when running) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
""")
if __name__ == "__main__":
main()