diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 46c86103ad..c1af32e2b2 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1,5 +1,5 @@ ######################################## -# Evergreen Template for MongoDB Drivers +# Evergreen Configuration for PyMongo ######################################## # When a task that used to pass starts to fail @@ -18,6 +18,12 @@ command_type: system exec_timeout_secs: 3600 # 60 minutes is the longest we'll ever run (primarily # for macos hosts) +# Ensure that setup and teardown is working as expected. +pre_error_fails_task: true +pre_timeout_secs: 1800 # 5 minutes +post_error_fails_task: true +post_timeout_secs: 1800 # 5 minutes + # What to do when evergreen hits the timeout (`post:` tasks are run automatically) timeout: - command: subprocess.exec @@ -35,8 +41,6 @@ pre: - func: "assume ec2 role" post: - # Disabled, causing timeouts - # - func: "upload working dir" - func: "teardown system" - func: "upload coverage" - func: "upload mo artifacts" diff --git a/.evergreen/just.sh b/.evergreen/just.sh index bebbca8282..65c3abbe80 100755 --- a/.evergreen/just.sh +++ b/.evergreen/just.sh @@ -2,4 +2,4 @@ set -eu . .evergreen/scripts/setup-dev-env.sh -just "$@" +${JUST_BINARY:-just} "$@" diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 2b7d856d41..5361582636 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -25,14 +25,16 @@ else exit 1 fi +UV=${UV_BINARY:-uv} + # List the packages. -uv sync ${UV_ARGS} --reinstall -uv pip list +$UV sync ${UV_ARGS} --reinstall +$UV pip list # Ensure we go back to base environment after the test. -trap "uv sync" EXIT HUP +trap "${UV} sync" EXIT HUP # Start the test runner. -uv run ${UV_ARGS} .evergreen/scripts/run_tests.py "$@" +$UV run ${UV_ARGS} .evergreen/scripts/run_tests.py "$@" popd diff --git a/.evergreen/scripts/configure-env.sh b/.evergreen/scripts/configure-env.sh index 81713f4191..22893db4e0 100755 --- a/.evergreen/scripts/configure-env.sh +++ b/.evergreen/scripts/configure-env.sh @@ -19,16 +19,6 @@ UV_CACHE_DIR=$PROJECT_DIRECTORY/.local/uv/cache DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS/.bin" MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" -# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME. -if [ "${CI:-}" == "true" ]; then - PYMONGO_BIN_DIR=${DRIVERS_TOOLS_BINARIES:-} -# We want to use a path that's already on PATH on spawn hosts. -else - PYMONGO_BIN_DIR=$HOME/cli_bin -fi - -PATH_EXT="$MONGODB_BINARIES:$DRIVERS_TOOLS_BINARIES:$PYMONGO_BIN_DIR:\$PATH" - # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) @@ -38,7 +28,6 @@ if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin UV_CACHE_DIR=$(cygpath -m "$UV_CACHE_DIR") DRIVERS_TOOLS_BINARIES=$(cygpath -m "$DRIVERS_TOOLS_BINARIES") MONGODB_BINARIES=$(cygpath -m "$MONGODB_BINARIES") - PYMONGO_BIN_DIR=$(cygpath -m "$PYMONGO_BIN_DIR") fi SCRIPT_DIR="$PROJECT_DIRECTORY/.evergreen/scripts" @@ -65,8 +54,6 @@ export CARGO_HOME="$CARGO_HOME" export UV_TOOL_DIR="$UV_TOOL_DIR" export UV_CACHE_DIR="$UV_CACHE_DIR" export UV_TOOL_BIN_DIR="$DRIVERS_TOOLS_BINARIES" -export PYMONGO_BIN_DIR="$PYMONGO_BIN_DIR" -export PATH="$PATH_EXT" # shellcheck disable=SC2154 export PROJECT="${project:-mongo-python-driver}" export PIP_QUIET=1 @@ -74,8 +61,8 @@ EOT # Write the .env file for drivers-tools. rm -rf $DRIVERS_TOOLS -BRANCH=master -ORG=mongodb-labs +BRANCH=fix-arch-handling +ORG=blink1073 git clone --branch $BRANCH https://github.com/$ORG/drivers-evergreen-tools.git $DRIVERS_TOOLS cat < ${DRIVERS_TOOLS}/.env @@ -91,23 +78,5 @@ DRIVERS_TOOLS: "$DRIVERS_TOOLS" PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" EOT -# If the toolchain is available, symlink binaries to the bin dir. This has to be done -# after drivers-tools is cloned, since we might be using its binary dir. -_bin_path="" -if [ "Windows_NT" == "${OS:-}" ]; then - _bin_path="/cygdrive/c/Python/Current/Scripts" -elif [ "$(uname -s)" != "Darwin" ]; then - _bin_path="/Library/Frameworks/Python.Framework/Versions/Current/bin" -else - _bin_path="/opt/python/Current/bin" -fi -if [ -d "${_bin_path}" ]; then - _suffix="" - if [ "Windows_NT" == "${OS:-}" ]; then - _suffix=".exe" - fi - mkdir -p $PYMONGO_BIN_DIR - ln -s ${_bin_path}/just${_suffix} $PYMONGO_BIN_DIR/just${_suffix} - ln -s ${_bin_path}/uv${_suffix} $PYMONGO_BIN_DIR/uv${_suffix} - ln -s ${_bin_path}/uvx${_suffix} $PYMONGO_BIN_DIR/uvx${_suffix} -fi +# Handle the binary dependencies. +bash $SCRIPT_DIR/install-dependencies.sh diff --git a/.evergreen/scripts/install-dependencies.sh b/.evergreen/scripts/install-dependencies.sh index 780d250a2b..3e7e776a0c 100755 --- a/.evergreen/scripts/install-dependencies.sh +++ b/.evergreen/scripts/install-dependencies.sh @@ -10,7 +10,16 @@ if [ -f $HERE/env.sh ]; then . $HERE/env.sh fi -_BIN_DIR=${PYMONGO_BIN_DIR:-$HOME/.local/bin} +# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME. +if [ "${CI:-}" == "true" ]; then + _BIN_DIR=${DRIVERS_TOOLS_BINARIES:-} +# We want to use a path that's already on PATH on spawn hosts. +elif [ -d "$HOME/cli_bin" ]; then + _BIN_DIR="$HOME/cli_bin" +else + _BIN_DIR="$HOME/.local/bin" +fi + export PATH="$PATH:${_BIN_DIR}" # Helper function to pip install a dependency using a temporary python env. @@ -38,6 +47,22 @@ function _pip_install() { } +# Try to use the binaries in the toolchain if available. +if [ -n "${CI}" ]; then + export PATH + case "${OSTYPE:?}" in + cygwin) + PATH="/cygdrive/c/Python/Current/Scripts:${PATH:-}" + ;; + darwin*) + PATH="/Library/Frameworks/Python.Framework/Versions/Current/bin:${PATH:-}" + ;; + *) + PATH="/opt/python/Current/bin:${PATH:-}" + ;; + esac +fi + # Ensure just is installed. if ! command -v just >/dev/null 2>&1; then # On most systems we can install directly. @@ -53,7 +78,7 @@ if ! command -v just >/dev/null 2>&1; then echo "Installing just... done." fi -# Install uv. +# Ensure uv is installed. if ! command -v uv >/dev/null 2>&1; then echo "Installing uv..." # On most systems we can install directly. @@ -66,4 +91,8 @@ if ! command -v uv >/dev/null 2>&1; then echo "Installing uv... done." fi +# Write the binary locations to the env file. +echo "UV_BINARY=$(which uv)" >> $HERE/env.sh +echo "JUST_BINARY=$(which just)" >> $HERE/env.sh + popd > /dev/null diff --git a/.evergreen/scripts/run-server.sh b/.evergreen/scripts/run-server.sh index 298eedcd3e..d4aaa9218b 100755 --- a/.evergreen/scripts/run-server.sh +++ b/.evergreen/scripts/run-server.sh @@ -10,4 +10,5 @@ if [ -f $HERE/env.sh ]; then source $HERE/env.sh fi -uv run $HERE/run_server.py "$@" +UV=${UV_BINARY:-uv} +$UV run $HERE/run_server.py "$@" diff --git a/.evergreen/scripts/setup-dev-env.sh b/.evergreen/scripts/setup-dev-env.sh index 6e6b5965bd..f3ad02a635 100755 --- a/.evergreen/scripts/setup-dev-env.sh +++ b/.evergreen/scripts/setup-dev-env.sh @@ -16,9 +16,6 @@ if [ -f $HERE/test-env.sh ]; then . $HERE/test-env.sh fi -# Ensure dependencies are installed. -bash $HERE/install-dependencies.sh - # Get the appropriate UV_PYTHON. . $ROOT/.evergreen/utils.sh @@ -32,11 +29,6 @@ fi export UV_PYTHON=${PYTHON_BINARY} echo "Using python $UV_PYTHON" -# Add the default install path to the path if needed. -if [ -z "${PYMONGO_BIN_DIR:-}" ]; then - export PATH="$PATH:$HOME/.local/bin" -fi - # Set up venv, making sure c extensions build unless disabled. if [ -z "${NO_EXT:-}" ]; then export PYMONGO_C_EXT_MUST_BUILD=1 @@ -47,13 +39,15 @@ if [ -f $HOME/.visualStudioEnv.sh ]; then SSH_TTY=1 source $HOME/.visualStudioEnv.sh set -u fi -uv sync --frozen + +UV=${UV_BINARY:-uv} +$UV sync --frozen echo "Setting up python environment... done." # Ensure there is a pre-commit hook if there is a git checkout. if [ -d .git ] && [ ! -f .git/hooks/pre-commit ]; then - uv run --frozen pre-commit install + $UV run --frozen pre-commit install fi popd > /dev/null diff --git a/.evergreen/scripts/setup-system.sh b/.evergreen/scripts/setup-system.sh index d8552e0ad2..f994cc5ed1 100755 --- a/.evergreen/scripts/setup-system.sh +++ b/.evergreen/scripts/setup-system.sh @@ -8,7 +8,6 @@ echo "Setting up system..." bash .evergreen/scripts/configure-env.sh source .evergreen/scripts/env.sh bash $DRIVERS_TOOLS/.evergreen/setup.sh -bash .evergreen/scripts/install-dependencies.sh popd # Enable core dumps if enabled on the machine diff --git a/.evergreen/scripts/setup-tests.sh b/.evergreen/scripts/setup-tests.sh index 0b75051a68..c8c3742b15 100755 --- a/.evergreen/scripts/setup-tests.sh +++ b/.evergreen/scripts/setup-tests.sh @@ -20,4 +20,5 @@ if [ -f $SCRIPT_DIR/env.sh ]; then source $SCRIPT_DIR/env.sh fi -uv run $SCRIPT_DIR/setup_tests.py "$@" +UV=${UV_BINARY:-uv} +$UV run $SCRIPT_DIR/setup_tests.py "$@" diff --git a/.evergreen/scripts/teardown-tests.sh b/.evergreen/scripts/teardown-tests.sh index 898425b6cf..381165e38a 100755 --- a/.evergreen/scripts/teardown-tests.sh +++ b/.evergreen/scripts/teardown-tests.sh @@ -21,4 +21,5 @@ else fi # Teardown the test runner. -uv run $SCRIPT_DIR/teardown_tests.py +UV=${UV_BINARY:-uv} +$UV run $SCRIPT_DIR/teardown_tests.py diff --git a/uv.lock b/uv.lock index 6bc0839795..aa23663a84 100644 --- a/uv.lock +++ b/uv.lock @@ -998,7 +998,6 @@ sdist = { url = "https://files.pythonhosted.org/packages/07/e9/ae44ea7d7605df9e5 [[package]] name = "pymongo" -version = "4.13.0.dev0" source = { editable = "." } dependencies = [ { name = "dnspython" },