From 6139dea9d30fdc9133b9e6c6483348a701ca357d Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Wed, 5 Aug 2026 19:11:00 +0530 Subject: [PATCH] fix: conditional requirements install and cross-platform venv activation Closes #143 Dockerfile: COPY /requirements.txt failed at build time for examples without a requirements.txt (web3, mcp-agents, gemini-quickstart). Copy the example first, then pip install only when requirements.txt exists. setup.sh: hardcoded .venv/bin/activate breaks on Windows Git Bash/MSYS2, where venv creates .venv/Scripts/activate. Source the correct script by checking both paths, and fail with a clear message if neither exists. --- Dockerfile | 11 +++++++---- setup.sh | 10 +++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae3e29ee..b2e63059 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app -COPY ${EXAMPLE}/requirements.txt ./requirements.txt -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r requirements.txt - COPY ${EXAMPLE}/ ./ +RUN if [ -f requirements.txt ]; then \ + pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt; \ + else \ + echo "No requirements.txt found — skipping dependency install."; \ + fi + RUN if [ -f .env.example ] && [ ! -f .env ]; then cp .env.example .env; fi ENTRYPOINT ["python"] diff --git a/setup.sh b/setup.sh index c0aee12d..1cbd330b 100755 --- a/setup.sh +++ b/setup.sh @@ -87,7 +87,15 @@ else echo "[2/4] Virtual environment already exists." fi -source .venv/bin/activate +if [[ -f ".venv/bin/activate" ]]; then + source .venv/bin/activate +elif [[ -f ".venv/Scripts/activate" ]]; then + source .venv/Scripts/activate +else + echo "Error: virtual environment activation script not found in .venv." >&2 + echo "Try deleting .venv and re-running this script." >&2 + exit 1 +fi if [[ -f "requirements.txt" ]]; then echo "[3/4] Installing dependencies..."