Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-25 08:29:13

0001 #!/bin/bash
0002 # Development Installation Script for SWF Testbed
0003 # This script sets up a complete development environment for the SWF testbed
0004 
0005 set -e  # Exit on any error
0006 
0007 echo "🚀 Setting up SWF Testbed Development Environment"
0008 echo "=================================================="
0009 
0010 # Check if we're in the right directory
0011 if [[ ! -f "pyproject.toml" ]] || [[ ! -d "src/swf_testbed_cli" ]]; then
0012     echo "❌ Error: This script must be run from the swf-testbed directory"
0013     echo "   Current directory: $(pwd)"
0014     exit 1
0015 fi
0016 
0017 # Check for required sibling directories
0018 SWF_PARENT_DIR=$(dirname "$(pwd)")
0019 export SWF_PARENT_DIR
0020 SWF_COMMON_LIB="$SWF_PARENT_DIR/swf-common-lib"
0021 SWF_MONITOR="$SWF_PARENT_DIR/swf-monitor"
0022 
0023 echo "📁 Checking for required repositories..."
0024 if [[ ! -d "$SWF_COMMON_LIB" ]]; then
0025     echo "❌ Error: swf-common-lib not found at $SWF_COMMON_LIB"
0026     echo "   Please clone: git clone https://github.com/BNLNPPS/swf-common-lib.git"
0027     exit 1
0028 fi
0029 
0030 if [[ ! -d "$SWF_MONITOR" ]]; then
0031     echo "❌ Error: swf-monitor not found at $SWF_MONITOR"
0032     echo "   swf-monitor is REQUIRED (contains core Django infrastructure and database models)"
0033     echo "   Please clone: git clone https://github.com/BNLNPPS/swf-monitor.git"
0034     exit 1
0035 fi
0036 
0037 echo "✅ All required repositories found"
0038 
0039 # Create virtual environment if it doesn't exist
0040 if [[ ! -d ".venv" ]]; then
0041     echo "🐍 Creating Python virtual environment..."
0042     python3 -m venv .venv
0043     echo "✅ Virtual environment created"
0044 else
0045     echo "✅ Virtual environment already exists"
0046 fi
0047 
0048 # Activate virtual environment
0049 echo "🔧 Activating virtual environment..."
0050 source .venv/bin/activate
0051 
0052 # Upgrade pip
0053 echo "📦 Upgrading pip..."
0054 python -m pip install --upgrade pip
0055 
0056 # Install dependencies in correct order
0057 echo "📦 Installing Python packages in dependency order..."
0058 
0059 echo "  1/4 Installing swf-common-lib (shared utilities)..."
0060 pip install -e "$SWF_COMMON_LIB"
0061 
0062 echo "  2/4 Installing swf-monitor dependencies..."
0063 if [[ -f "$SWF_MONITOR/requirements.txt" ]]; then
0064     pip install -r "$SWF_MONITOR/requirements.txt"
0065 else
0066     echo "    No requirements.txt found in swf-monitor"
0067 fi
0068 
0069 echo "  3/4 Installing swf-monitor (core Django infrastructure)..."
0070 pip install -e "$SWF_MONITOR"
0071 
0072 echo "  4/4 Installing swf-testbed CLI and core dependencies..."
0073 # Install core dependencies first
0074 pip install typer[all] supervisor psutil
0075 # Install testbed without trying to resolve the swf-* dependencies from PyPI
0076 pip install -e . --no-deps
0077 
0078 echo "✅ All packages installed successfully"
0079 
0080 # Environment setup is now automatic when running swf-testbed commands
0081 echo "🌍 Environment setup will be automatic when using swf-testbed commands..."
0082 
0083 echo ""
0084 echo "🎉 Development environment setup complete!"
0085 echo ""
0086 echo "📋 Next steps:"
0087 echo "   1. Activate the virtual environment: source .venv/bin/activate"
0088 echo "   2. Configure swf-monitor secrets: cd ../swf-monitor && cp .env.example .env"
0089 echo "      Then edit .env with your database credentials (DB_PASSWORD='admin')"
0090 echo "   3. Initialize testbed: swf-testbed init"
0091 echo "   4. Start services:"
0092 echo "      - With Docker: swf-testbed start"
0093 echo "      - With local services: swf-testbed start-local"
0094 echo ""
0095 echo "🔍 Available commands:"
0096 echo "   swf-testbed init     - Initialize testbed configuration"
0097 echo "   swf-testbed start    - Start testbed with Docker services"
0098 echo "   swf-testbed start-local - Start testbed with local services"
0099 echo "   swf-testbed status   - Check status of services"
0100 echo "   swf-testbed stop     - Stop all services"
0101 echo ""