|
|
|
|
|
"""
|
|
|
Development setup script.
|
|
|
Creates necessary directories and validates configuration.
|
|
|
"""
|
|
|
|
|
|
import os
|
|
|
import sys
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
def create_directories():
|
|
|
"""Create necessary directories for the application."""
|
|
|
directories = [
|
|
|
"uploads",
|
|
|
"videos",
|
|
|
"logs",
|
|
|
"data",
|
|
|
]
|
|
|
|
|
|
for directory in directories:
|
|
|
Path(directory).mkdir(exist_ok=True)
|
|
|
print(f"β Created directory: {directory}")
|
|
|
|
|
|
|
|
|
def check_env_file():
|
|
|
"""Check if .env file exists and create from example if not."""
|
|
|
env_file = Path(".env")
|
|
|
env_example = Path(".env.example")
|
|
|
|
|
|
if not env_file.exists():
|
|
|
if env_example.exists():
|
|
|
|
|
|
env_file.write_text(env_example.read_text())
|
|
|
print("β Created .env file from .env.example")
|
|
|
print("β οΈ Please update the .env file with your actual configuration values")
|
|
|
else:
|
|
|
print("β .env.example file not found")
|
|
|
return False
|
|
|
else:
|
|
|
print("β .env file already exists")
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
def validate_required_env_vars():
|
|
|
"""Validate that required environment variables are set."""
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
required_vars = [
|
|
|
"CLERK_SECRET_KEY",
|
|
|
"CLERK_PUBLISHABLE_KEY",
|
|
|
"SECRET_KEY",
|
|
|
]
|
|
|
|
|
|
missing_vars = []
|
|
|
for var in required_vars:
|
|
|
if not os.getenv(var) or os.getenv(var) == f"your_{var.lower()}_here":
|
|
|
missing_vars.append(var)
|
|
|
|
|
|
if missing_vars:
|
|
|
print("β Missing required environment variables:")
|
|
|
for var in missing_vars:
|
|
|
print(f" - {var}")
|
|
|
print("\nPlease update your .env file with actual values.")
|
|
|
return False
|
|
|
|
|
|
print("β All required environment variables are set")
|
|
|
return True
|
|
|
|
|
|
|
|
|
def main():
|
|
|
"""Main setup function."""
|
|
|
print("π Setting up FastAPI Video Backend development environment...\n")
|
|
|
|
|
|
|
|
|
create_directories()
|
|
|
print()
|
|
|
|
|
|
|
|
|
if not check_env_file():
|
|
|
sys.exit(1)
|
|
|
print()
|
|
|
|
|
|
|
|
|
try:
|
|
|
if not validate_required_env_vars():
|
|
|
print("\nβ οΈ Setup completed with warnings. Please fix the issues above.")
|
|
|
sys.exit(1)
|
|
|
except ImportError:
|
|
|
print("β οΈ python-dotenv not installed. Skipping environment validation.")
|
|
|
print(" Install dependencies with: pip install -e .")
|
|
|
|
|
|
print("\nβ
Development environment setup completed!")
|
|
|
print("\nNext steps:")
|
|
|
print("1. Install dependencies: pip install -e .")
|
|
|
print("2. Update .env file with your actual configuration values")
|
|
|
print("3. Start Redis server: redis-server")
|
|
|
print("4. Run the application: python -m src.app.main")
|
|
|
print("5. Visit http://localhost:8000/docs for API documentation")
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main() |