Skip to content

fix: conditional requirements install and cross-platform venv activation - #177

Open
saurabhhhcodes wants to merge 1 commit into
fetchai:mainfrom
saurabhhhcodes:fix/dockerfile-setup-conditional-venv
Open

fix: conditional requirements install and cross-platform venv activation#177
saurabhhhcodes wants to merge 1 commit into
fetchai:mainfrom
saurabhhhcodes:fix/dockerfile-setup-conditional-venv

Conversation

@saurabhhhcodes

Copy link
Copy Markdown

Closes #143

Problem

  1. Dockerfile unconditionally ran COPY ${EXAMPLE}/requirements.txt — build crashes for examples without a requirements.txt (web3, mcp-agents, gemini-quickstart).
  2. setup.sh hardcoded source .venv/bin/activate — fails on Windows Git Bash/MSYS2, where venv creates .venv/Scripts/activate.

Changes

Dockerfile

  • Copy ${EXAMPLE}/ first, then install requirements only when the file exists:
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

setup.sh

  • Activate the venv from whichever path exists:
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

Verification

  • bash -n setup.sh — syntax OK
  • Requirement-present / requirement-absent branches exercised in shell (skip message vs install path)
  • Docker daemon not available locally; the RUN logic is plain POSIX if/else validated standalone

Closes fetchai#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.
@github-actions github-actions Bot added gssoc26 GirlScript Summer of Code 2026 contribution level2 GSSoC level 2 - intermediate (medium points) labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GirlScript Summer of Code 2026 contribution level2 GSSoC level 2 - intermediate (medium points)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfile and setup.sh fail for examples without requirements.txt and on Windows environments

1 participant