diff --git a/.evergreen/scripts/configure-env.sh b/.evergreen/scripts/configure-env.sh index f23af8a811..fa37b8fb08 100755 --- a/.evergreen/scripts/configure-env.sh +++ b/.evergreen/scripts/configure-env.sh @@ -92,3 +92,24 @@ cat < expansion.yml 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 diff --git a/.evergreen/scripts/install-dependencies.sh b/.evergreen/scripts/install-dependencies.sh index 31ae4c1735..5ec06a87df 100755 --- a/.evergreen/scripts/install-dependencies.sh +++ b/.evergreen/scripts/install-dependencies.sh @@ -24,10 +24,14 @@ function _pip_install() { echo "Installing $2 using pip..." createvirtualenv "$(find_python3)" $_VENV_PATH python -m pip install $1 + _suffix="" if [ "Windows_NT" = "${OS:-}" ]; then - ln -s "$(which $2)" $_BIN_DIR/$2.exe - else - ln -s "$(which $2)" $_BIN_DIR/$2 + _suffix=".exe" + fi + ln -s "$(which $2)" $_BIN_DIR/${2}${_suffix} + # uv also comes with a uvx binary. + if [ $2 == "uv" ]; then + ln -s "$(which uvx)" $_BIN_DIR/uvx${_suffix} fi echo "Installed to ${_BIN_DIR}" echo "Installing $2 using pip... done." diff --git a/.evergreen/scripts/utils.py b/.evergreen/scripts/utils.py index dcb50cc4dc..ef98b16470 100644 --- a/.evergreen/scripts/utils.py +++ b/.evergreen/scripts/utils.py @@ -136,5 +136,10 @@ def run_command(cmd: str | list[str], **kwargs: Any) -> None: cmd = " ".join(cmd) LOGGER.info("Running command '%s'...", cmd) kwargs.setdefault("check", True) - subprocess.run(shlex.split(cmd), **kwargs) # noqa: PLW1510, S603 + try: + subprocess.run(shlex.split(cmd), **kwargs) # noqa: PLW1510, S603 + except subprocess.CalledProcessError as e: + LOGGER.error(e.output) + LOGGER.error(str(e)) + sys.exit(e.returncode) LOGGER.info("Running command '%s'... done.", cmd) diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index e044b3d766..bb3ed8dabd 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -4,31 +4,29 @@ set -eu find_python3() { PYTHON="" - # Add a fallback system python3 if it is available and Python 3.9+. - if is_python_39 "$(command -v python3)"; then - PYTHON="$(command -v python3)" - fi # Find a suitable toolchain version, if available. if [ "$(uname -s)" = "Darwin" ]; then - # macos 11.00 - if [ -d "/Library/Frameworks/Python.Framework/Versions/3.10" ]; then - PYTHON="/Library/Frameworks/Python.Framework/Versions/3.10/bin/python3" - # macos 10.14 - elif [ -d "/Library/Frameworks/Python.Framework/Versions/3.9" ]; then - PYTHON="/Library/Frameworks/Python.Framework/Versions/3.9/bin/python3" - fi + PYTHON="/Library/Frameworks/Python.Framework/Versions/Current/bin/python3" elif [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin - PYTHON="C:/python/Python39/python.exe" + PYTHON="C:/python/Current/python.exe" else # Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.9+. - if [ -f "/opt/python/3.9/bin/python3" ]; then - PYTHON="/opt/python/3.9/bin/python3" + if [ -f "/opt/python/Current/bin/python3" ]; then + PYTHON="/opt/python/Current/bin/python3" + elif is_python_39 "$(command -v /opt/mongodbtoolchain/v5/bin/python3)"; then + PYTHON="/opt/mongodbtoolchain/v5/bin/python3" elif is_python_39 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then PYTHON="/opt/mongodbtoolchain/v4/bin/python3" elif is_python_39 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then PYTHON="/opt/mongodbtoolchain/v3/bin/python3" fi fi + # Add a fallback system python3 if it is available and Python 3.9+. + if [ -z "$PYTHON" ]; then + if is_python_39 "$(command -v python3)"; then + PYTHON="$(command -v python3)" + fi + fi if [ -z "$PYTHON" ]; then echo "Cannot test without python3.9+ installed!" exit 1