ComfyUI-Manager/tests/setup_test_env.sh
Dr.Lt.Data 2866193baf ● feat: Draft pip package policy management system (not yet integrated)
Add comprehensive pip dependency conflict resolution framework as draft implementation. This is self-contained and does not affect existing
ComfyUI Manager functionality.

Key components:
- pip_util.py with PipBatch class for policy-driven package management
- Lazy-loaded policy system supporting base + user overrides
- Multi-stage policy execution (uninstall → apply_first_match → apply_all_matches → restore)
- Conditional policies based on platform, installed packages, and ComfyUI version
- Comprehensive test suite covering edge cases, workflows, and platform scenarios
- Design and implementation documentation

Policy capabilities (draft):
- Package replacement (e.g., PIL → Pillow, opencv-python → opencv-contrib-python)
- Version pinning to prevent dependency conflicts
- Dependency protection during installations
- Platform-specific handling (Linux/Windows, GPU detection)
- Pre-removal and post-restoration workflows

Testing infrastructure:
- Pytest-based test suite with isolated environments
- Dependency analysis tools for conflict detection
- Coverage for policy priority, edge cases, and environment recovery

Status: Draft implementation complete, integration with manager workflows pending.
2025-10-04 08:55:59 +09:00

76 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# Test Environment Setup Script for pip_util.py
# Creates isolated venv to prevent environment corruption
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VENV_DIR="${SCRIPT_DIR}/test_venv"
echo "=================================================="
echo "pip_util.py Test Environment Setup"
echo "=================================================="
echo ""
# Check Python version
PYTHON_CMD=""
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
else
echo "❌ Error: Python not found. Please install Python 3.8 or higher."
exit 1
fi
PYTHON_VERSION=$($PYTHON_CMD --version 2>&1 | awk '{print $2}')
echo "✓ Found Python: $PYTHON_VERSION"
# Remove existing venv if present
if [ -d "$VENV_DIR" ]; then
echo ""
read -p "⚠️ Existing test venv found. Remove and recreate? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "🗑️ Removing existing venv..."
rm -rf "$VENV_DIR"
else
echo "Keeping existing venv. Skipping creation."
exit 0
fi
fi
# Create venv
echo ""
echo "📦 Creating virtual environment..."
$PYTHON_CMD -m venv "$VENV_DIR"
# Activate venv
echo "🔌 Activating virtual environment..."
source "${VENV_DIR}/bin/activate"
# Upgrade pip
echo "⬆️ Upgrading pip..."
pip install --upgrade pip
# Install test dependencies
echo ""
echo "📚 Installing test dependencies..."
pip install -r "${SCRIPT_DIR}/requirements.txt"
echo ""
echo "=================================================="
echo "✅ Test environment setup complete!"
echo "=================================================="
echo ""
echo "To activate the test environment:"
echo " source ${VENV_DIR}/bin/activate"
echo ""
echo "To run tests:"
echo " pytest"
echo ""
echo "To deactivate:"
echo " deactivate"
echo ""