Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions .evergreen/scripts/setup-uv-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,33 @@
# 3.10 when the task does not set one.
set -euo pipefail

HERE=$(dirname ${BASH_SOURCE:-$0})
HERE=$(dirname "${BASH_SOURCE:-$0}")
HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )"
ROOT=$(dirname "$(dirname "$HERE")")

# A .venv whose interpreter was removed breaks every `uv python find` and
# `uv sync`. It is a build artifact, so remove it and let `uv sync` recreate it.
# A removed base interpreter leaves a dangling symlink on Linux/macOS and a
# launcher that will not start on Windows, so probe by running the interpreter.
for _py in "$ROOT/.venv/bin/python3" "$ROOT/.venv/bin/python" "$ROOT/.venv/Scripts/python.exe"; do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any interest in supporting Windows? 😄

E.g.

  # A .venv whose base interpreter is gone breaks every `uv python find` and
  # `uv sync`. It is a build artifact, so remove it and let `uv sync` recreate it.
  _venv_py=""
  for _py in "$ROOT/.venv/bin/python" "$ROOT/.venv/Scripts/python.exe"; do
    if [ -x "$_py" ]; then
      _venv_py="$_py"
      break
    fi
  done
  if [ -n "$_venv_py" ] && ! "$_venv_py" -c 'import sys' > /dev/null 2>&1; then
    echo "Removing broken .venv (its interpreter will not start); uv sync will recreate it."
    rm -rf "$ROOT/.venv"
  fi
  unset _py _venv_py

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure why not. 😄

if [ -e "$_py" ] || [ -L "$_py" ]; then
if ! "$_py" -c 'import sys' > /dev/null 2>&1; then
echo "Removing broken .venv (its interpreter will not start); uv sync will recreate it."
rm -rf "$ROOT/.venv"
fi
break
fi
done
unset _py

# Source the env files to pick up common variables.
if [ -f $HERE/env.sh ]; then
. $HERE/env.sh
if [ -f "$HERE/env.sh" ]; then
. "$HERE/env.sh"
fi

# Get variables defined in test-env.sh.
if [ -f $HERE/test-env.sh ]; then
. $HERE/test-env.sh
if [ -f "$HERE/test-env.sh" ]; then
. "$HERE/test-env.sh"
fi

# Default to a known-good Python so behavior is deterministic when a task does
Expand Down Expand Up @@ -59,15 +75,30 @@ function _toolchain_dir() {
}

# Make sure uv can provide the requested Python, downloading it if needed.
# If that fails, fall back to any available Python on local hosts; on CI, fail.
function _ensure_python() {
local request="$1"
if uv python find "$request" > /dev/null 2>&1; then
local request="$1" out _fallback
if out=$(uv python find "$request" 2>&1); then
return 0
fi
echo "Python \"$request\" was not found on this host; asking uv to install it..."
# Show why find failed: e.g. an interpreter uv cannot run, or none at all.
echo "Python \"$request\" was not found on this host:" >&2
sed 's/^/ /' <<<"$out" >&2
echo "Asking uv to install Python \"$request\"..."
if uv python install "$request"; then
return 0
fi
echo "uv could not install Python \"$request\"; looking for another interpreter..."
# Ignore UV_PYTHON and friends: they would steer the fallback right back to
# the broken interpreter. Local setup only: the Evergreen agent exports
# CI=true for every task command.
if [ "${CI:-}" != "true" ] && \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care to check for Evergreen here (where this won't ever be true)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still could be true for a new version of python, like 3.16alpha

_fallback=$(env -u UV_PYTHON -u UV_PYTHON_SEARCH_PATH -u UV_PYTHON_PREFERENCE \
uv python find ">=3.9" 2>/dev/null); then
echo "Using fallback interpreter: $_fallback"
export UV_PYTHON="$_fallback"
return 0
fi
echo "ERROR: uv could not find or install Python \"$request\"." >&2
return 1
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-mod-wsgi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
uv pip install -r requirements/mod_wsgi.txt
uv run --no-sync python tools/fail_if_no_c.py
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@49da51cebc0060b4d699d57bdef30ee7e071de44
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
with:
version: ${{ steps.versions.outputs.mongodb-version }}
topology: "replica_set"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
# The beta Python here relies on the action's prerelease default.
python-version: ${{ matrix.python-version }}
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
Comment thread
blink1073 marked this conversation as resolved.
with:
version: "${{ matrix.mongodb-version }}"
- name: Run tests
Expand All @@ -107,7 +107,7 @@ jobs:
with:
python-version: "3.10"
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
with:
version: "8.0"
- name: Setup tests
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Install dependencies
run: just install
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
with:
version: "8.0"
- name: Run tests
Expand Down Expand Up @@ -194,12 +194,12 @@ jobs:
- name: Install dependencies
run: just install
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
- name: Run tests
run: |
just integration-tests
- id: setup-mongodb-ssl
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
with:
ssl: true
- name: Run tests
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
# Test sdist on lowest supported Python
python-version: "3.9"
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
- name: Run connect test from sdist
shell: bash
run: |
Expand All @@ -278,7 +278,7 @@ jobs:
with:
python-version: "3.9"
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@ec0b1497b3d351acbfc4fd7579bf3de4de0a1046 # v1.1.0
uses: mongodb-labs/drivers-evergreen-tools@354a81692bfd2b654a38277b681d248507d17800 # v1.2.0
with:
version: "8.0"
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion drivers-evergreen-tools
Submodule drivers-evergreen-tools updated 47 files
+17 −2 .evergreen/auth_aws/README.md
+29 −26 .evergreen/auth_aws/activate-authawsvenv.sh
+6 −3 .evergreen/auth_aws/aws_setup.sh
+9 −0 .evergreen/auth_aws/pyproject.toml
+0 −6 .evergreen/auth_aws/requirements-in.txt
+0 −92 .evergreen/auth_aws/requirements.txt
+5 −2 .evergreen/auth_aws/teardown.sh
+1 −1 .evergreen/auth_oidc/requirements.txt
+16 −2 .evergreen/config.yml
+7 −0 .evergreen/docker/README.md
+0 −49 .evergreen/docker/activate-dockerenv.sh
+9 −0 .evergreen/docker/pyproject.toml
+0 −2 .evergreen/docker/requirements-in.txt
+0 −37 .evergreen/docker/requirements.txt
+5 −2 .evergreen/docker/setup.sh
+45 −16 .evergreen/install-cli.sh
+59 −7 .evergreen/mongodl.py
+11 −0 .evergreen/orchestration/README.md
+7 −9 .evergreen/orchestration/drivers_orchestration.py
+1,724 −0 .evergreen/orchestration/mongodb-runner/4.2/package-lock.json
+8 −0 .evergreen/orchestration/mongodb-runner/4.2/package.json
+38 −0 .evergreen/orchestration/mongodb-runner/README.md
+51 −0 .evergreen/orchestration/mongodb-runner/check-pins.sh
+1,757 −0 .evergreen/orchestration/mongodb-runner/default/package-lock.json
+7 −0 .evergreen/orchestration/mongodb-runner/default/package.json
+97 −23 .evergreen/orchestration/mongodb_runner.py
+1 −4 .evergreen/orchestration/pyproject.toml
+1 −0 .evergreen/orchestration/setup.sh
+0 −450 .evergreen/orchestration/uv.lock
+6 −4 .evergreen/secrets_handling/setup-secrets.sh
+267 −8 .evergreen/server_artifacts.py
+3 −3 .evergreen/setup.sh
+220 −0 .evergreen/tests/test-cli.py
+53 −8 .evergreen/tests/test-cli.sh
+34 −10 .evergreen/tests/test-install-binaries.sh
+53 −4 .evergreen/tests/test-mongodb-runner.sh
+6 −1 .evergreen/tests/test-otel.sh
+0 −184 .evergreen/uv.lock
+14 −3 .github/dependabot.yml
+11 −0 .gitignore
+5 −0 .pre-commit-config.yaml
+13 −8 AGENTS.md
+5 −5 CONTRIBUTING.md
+20 −1 README.md
+46 −0 pyproject.toml
+1 −0 ruff.toml
+1,591 −0 uv.lock
Loading