fix: fix setup_mcp.sh to detect and use virtual environments (#163)

##  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)
This commit is contained in:
Hafez
2025-11-06 21:46:36 +01:00
committed by GitHub
parent c775b40cf7
commit fd679e2298

View File

@@ -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