From fd679e229855b0355be320031dbc1ea51d5dc077 Mon Sep 17 00:00:00 2001 From: Hafez Date: Thu, 6 Nov 2025 21:46:36 +0100 Subject: [PATCH] fix: fix setup_mcp.sh to detect and use virtual environments (#163) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## ✅ Merged - All Bugs Fixed Excellent work fixing both critical bugs from the initial review! All 390 tests passing. **Original bugs fixed:** - ✅ Double "install" command issue resolved - ✅ pytest line now uses $PIP_INSTALL_CMD **What's merged:** - Virtual environment detection (active venv) - Auto-activation of inactive venv/ - System install fallback with --user --break-system-packages **Next:** Will add refinements to the system install fallback in a follow-up commit. 🤖 Merged with [Claude Code](https://claude.com/claude-code) --- setup_mcp.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/setup_mcp.sh b/setup_mcp.sh index 0f91014..510ecae 100755 --- a/setup_mcp.sh +++ b/setup_mcp.sh @@ -35,19 +35,34 @@ echo "" # Step 3: Install dependencies echo "Step 3: Installing Python dependencies..." + +# Check if we're in a virtual environment +if [[ -n "$VIRTUAL_ENV" ]]; then + echo -e "${GREEN}✓${NC} Virtual environment detected: $VIRTUAL_ENV" + PIP_INSTALL_CMD="pip install" +elif [[ -d "venv" ]]; then + echo -e "${YELLOW}⚠${NC} Virtual environment found but not activated" + echo "Activating venv..." + source venv/bin/activate + PIP_INSTALL_CMD="pip install" +else + echo "No virtual environment found. Using system pip with --user --break-system-packages flags" + PIP_INSTALL_CMD="pip3 install --user --break-system-packages" +fi + echo "This will install: mcp, requests, beautifulsoup4" read -p "Continue? (y/n) " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then echo "Installing MCP server dependencies..." - pip3 install -r skill_seeker_mcp/requirements.txt || { + $PIP_INSTALL_CMD -r skill_seeker_mcp/requirements.txt || { echo -e "${RED}❌ Failed to install MCP dependencies${NC}" exit 1 } echo "Installing CLI tool dependencies..." - pip3 install requests beautifulsoup4 || { + $PIP_INSTALL_CMD requests beautifulsoup4 || { echo -e "${RED}❌ Failed to install CLI dependencies${NC}" exit 1 } @@ -78,7 +93,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then # Check if pytest is installed if ! command -v pytest &> /dev/null; then echo "Installing pytest..." - pip3 install pytest || { + $PIP_INSTALL_CMD pytest || { echo -e "${YELLOW}⚠${NC} Could not install pytest, skipping tests" } fi