#!/usr/bin/env python3 """ Installation script for FastStream dependencies. This script installs FastStream with Redis support and updates the project configuration to use FastStream instead of Celery. """ import subprocess import sys import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) def run_command(command: str) -> bool: """ Run a shell command and return success status. Args: command: Command to execute Returns: True if command succeeded, False otherwise """ try: logger.info(f"Running: {command}") result = subprocess.run( command.split(), check=True, capture_output=True, text=True ) logger.info(f"Success: {result.stdout}") return True except subprocess.CalledProcessError as e: logger.error(f"Failed: {e.stderr}") return False def main() -> None: """Main installation function.""" logger.info("Installing FastStream dependencies...") # Install FastStream with Redis support if not run_command("uv add faststream[redis]"): logger.error("Failed to install faststream[redis]") sys.exit(1) # Install TaskIQ-FastStream for scheduling if not run_command("uv add taskiq-faststream"): logger.error("Failed to install taskiq-faststream") sys.exit(1) # Remove Celery (optional) logger.info("Removing Celery dependency...") run_command("uv remove celery") # Don't fail if this doesn't work logger.info("FastStream installation completed successfully!") logger.info("You can now start the FastStream worker with:") logger.info(" uv run faststream run workers.broker:app") if __name__ == "__main__": main()