From c54f8998bd5587be6f5251406ca33754028ed33b Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Mon, 8 Jun 2026 13:30:25 +0530 Subject: [PATCH] fix: tolerate examples without requirements --- Dockerfile | 11 +++++++---- setup.sh | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae3e29ee..8458e153 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 pip install --no-cache-dir --upgrade pip && \ + if [ -f requirements.txt ]; then \ + pip install --no-cache-dir -r requirements.txt; \ + else \ + echo "No requirements.txt found for ${EXAMPLE}; 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..07ffec09 100755 --- a/setup.sh +++ b/setup.sh @@ -87,7 +87,18 @@ else echo "[2/4] Virtual environment already exists." fi -source .venv/bin/activate +ACTIVATE_SCRIPT="" +if [[ -f ".venv/bin/activate" ]]; then + ACTIVATE_SCRIPT=".venv/bin/activate" +elif [[ -f ".venv/Scripts/activate" ]]; then + ACTIVATE_SCRIPT=".venv/Scripts/activate" +else + echo "Error: Could not find a virtual environment activation script." + echo "Expected .venv/bin/activate or .venv/Scripts/activate." + exit 1 +fi + +source "$ACTIVATE_SCRIPT" if [[ -f "requirements.txt" ]]; then echo "[3/4] Installing dependencies..." @@ -118,7 +129,7 @@ echo "" echo "=== Setup Complete ===" echo "" echo "To activate the environment:" -echo " cd $EXAMPLE && source .venv/bin/activate" +echo " cd $EXAMPLE && source $ACTIVATE_SCRIPT" echo "" if [[ -n "$ENTRY_FILE" ]]; then