Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
50 changes: 29 additions & 21 deletions .evergreen/install-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if ! command -V uv &>/dev/null; then
echo "Installing uv using pip..."
venvcreate "$DRIVERS_TOOLS_PYTHON" "$_venv_dir"
# Install uv into the newly created venv.
python -m pip install -q --force-reinstall -r requirements-cli.txt
python -m pip install -q --force-reinstall uv
_suffix=""
# Symlink uv and uvx binaries.
_install_dir="${DRIVERS_TOOLS}/.bin"
Expand Down Expand Up @@ -99,32 +99,40 @@ uv venv venv &>/dev/null
popd >/dev/null # $SCRIPT_DIR
pushd "$TARGET_DIR" >/dev/null

# uv requires UV_TOOL_BIN_DIR is `C:\a\b\c` instead of `/cygdrive/c/a/b/c` on Windows.
if [[ "${OSTYPE:?}" == cygwin ]]; then
UV_TOOL_BIN_DIR="$(cygpath -aw .)"
else
UV_TOOL_BIN_DIR="$(pwd)"
fi
export UV_TOOL_BIN_DIR

# Pin the uv binary version used by subsequent commands.
uv tool install -q --force "uv~=0.8.0"
PATH="${UV_TOOL_BIN_DIR:?}:${PATH:-}"
command -V uv
uv --version

# Workaround for https://github.com/astral-sh/uv/issues/5815.
uv export --quiet --frozen --format requirements.txt -o uv-requirements.txt

# Support overriding lockfile dependencies.
if [[ ! -f "${DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES:-}" ]]; then
printf "" >|"${DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES:="uv-override-dependencies.txt"}"
fi

declare uv_install_args
uv_install_args=(
--quiet
--force
--editable
--with certifi
--with-requirements uv-requirements.txt
--overrides "${DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES:?}"
)
uv tool install "${uv_install_args[@]:?}" .

# Preserve pymongo compatibility with the requested server version.
case "${MONGODB_VERSION:-"latest"}" in
3.6) uv_install_args+=(--with "pymongo<4.11") ;;
4.0) uv_install_args+=(--with "pymongo<4.14") ;;
esac

# On Windows, we have to do a bit of path manipulation.
if [ "Windows_NT" == "${OS:-}" ]; then
TMP_DIR=$(cygpath -m "$(mktemp -d)")
PATH="$SCRIPT_DIR/venv/Scripts:$PATH"
UV_TOOL_BIN_DIR=${TMP_DIR} uv tool install "${uv_install_args[@]:?}" .
filenames=$(ls ${TMP_DIR})
for filename in $filenames; do
mv $TMP_DIR/$filename "$1/${filename//.exe/}"
done
rm -rf $TMP_DIR
else
UV_TOOL_BIN_DIR=$(pwd) uv tool install "${uv_install_args[@]:?}" .
fi
# Support running tool executables on Windows without including the ".exe" suffix.
find . -maxdepth 1 -type f -name '*.exe' -exec \
bash -c "ln -sf \"\$0\" \"\$(echo \"\$0\" | sed -E -e 's|(.*)\.exe|\1|')\"" {} \;

popd >/dev/null # "$TARGET_DIR"
2 changes: 1 addition & 1 deletion .evergreen/orchestration/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"
name = "drivers-orchestration"
version = "0.1.0"
description = 'Scripts for drivers orchestration'
requires-python = ">=3.8"
requires-python = ">=3.9"
license = "MIT"
keywords = []
authors = [
Expand Down
18 changes: 14 additions & 4 deletions .evergreen/orchestration/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@

set -o errexit

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/../handle-paths.sh
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
. "${SCRIPT_DIR:?}/../handle-paths.sh"

export DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES
DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES="${SCRIPT_DIR:?}/uv-override-dependencies.txt"
printf "" >|"${DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES:?}"

# Preserve pymongo compatibility with the requested server version.
case "${MONGODB_VERSION:-"latest"}" in
3.6) echo "pymongo<4.11" >>"${DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES:?}" ;;
4.0) echo "pymongo<4.14" >>"${DRIVERS_TOOLS_INSTALL_CLI_OVERRIDES:?}" ;;
esac

# Install CLIs into this directory (default path for $PROJECT_ORCHESTRATION_HOME
# and $MONGO_ORCHESTRATION_HOME) and the parent directory ($DRIVERS_TOOLS).
bash $SCRIPT_DIR/../install-cli.sh $SCRIPT_DIR/..
bash $SCRIPT_DIR/../install-cli.sh $SCRIPT_DIR
bash "${SCRIPT_DIR:?}/../install-cli.sh" "${SCRIPT_DIR:?}/.."
bash "${SCRIPT_DIR:?}/../install-cli.sh" "${SCRIPT_DIR:?}"
282 changes: 282 additions & 0 deletions .evergreen/orchestration/uv.lock

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions .evergreen/requirements-cli.txt

This file was deleted.

1 change: 0 additions & 1 deletion .evergreen/requirements-in-cli.txt

This file was deleted.

8 changes: 8 additions & 0 deletions .evergreen/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ container_id.txt
bin
perf-report.md
perf-report.txt
uv-requirements.txt
uv-override-dependencies.txt

# Azure functions.
.python_packages/
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ export TLS_PEM_KEY_FILE=<path-to>/server.pem
export TLS_CA_FILE=<path-to>/ca.pem
```

## Updating Dependencies

The MongoDB server management scripts under [`.evergreen/orchestration`](https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/orchestration)
depend on [PyMongo](https://pymongo.readthedocs.io/en/stable/). Package dependencies are pinned by the
[`.evergreen/orchestration/uv.lock`](https://github.com/eramongodb/drivers-evergreen-tools/blob/master/.evergreen/orchestration/uv.lock)
lockfile. When the lockfile is updated, ensure the updated PyMongo version still supports old server versions which are
still in use by downstream projects.

If a [recent release](https://pymongo.readthedocs.io/en/stable/changelog.html) of PyMongo drops support for an old
server version that is still in use by downstream projects, add a dependency override to
[`.evergreen/orchestration/setup.sh`](https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/orchestration/setup.sh).
Otherwise, an error similar to the following may occur during mongo-orchestration operations (e.g. with server 4.0 and
PyMongo 4.14):

```
[ERROR] mongo_orchestration.apps:68 - ...
Traceback (most recent call last):
...
File ".../drivers-orchestration/lib/python3.13/site-packages/pymongo/synchronous/topology.py", line 369, in _select_servers_loop
self._description.check_compatible()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File ".../drivers-orchestration/lib/python3.13/site-packages/pymongo/topology_description.py", line 168, in check_compatible
raise ConfigurationError(self._incompatible_err)
pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 7, but this version of PyMongo requires at least 8 (MongoDB 4.2).
```

The dependency override may be removed once all downstream projects have also dropped support for the old server version.

## Linters and Formatters

This repo uses [pre-commit](https://pre-commit.com/) for managing linting and formatting of the codebase.
Expand Down
Loading