Skip to content

PYTHON-5298 Account for update to uv lockfile format #2298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
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
10 changes: 7 additions & 3 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
########################################
# Evergreen Template for MongoDB Drivers
# Evergreen Configuration for PyMongo
########################################

# When a task that used to pass starts to fail
Expand All @@ -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
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/just.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -eu

. .evergreen/scripts/setup-dev-env.sh
just "$@"
${JUST_BINARY:-just} "$@"
10 changes: 6 additions & 4 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 4 additions & 35 deletions .evergreen/scripts/configure-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand All @@ -65,17 +54,15 @@ 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
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 <<EOT > ${DRIVERS_TOOLS}/.env
Expand All @@ -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
33 changes: 31 additions & 2 deletions .evergreen/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
3 changes: 2 additions & 1 deletion .evergreen/scripts/run-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
14 changes: 4 additions & 10 deletions .evergreen/scripts/setup-dev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion .evergreen/scripts/setup-system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/scripts/setup-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
3 changes: 2 additions & 1 deletion .evergreen/scripts/teardown-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion uv.lock

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