1414PROJECT_DIRECTORY=" $( pwd) "
1515DRIVERS_TOOLS=" $( dirname $PROJECT_DIRECTORY ) /drivers-tools"
1616CARGO_HOME=${CARGO_HOME:- ${DRIVERS_TOOLS} / .cargo}
17- UV_TOOL_DIR=$PROJECT_DIRECTORY /.local/uv/tools
18- UV_CACHE_DIR=$PROJECT_DIRECTORY /.local/uv/cache
1917DRIVERS_TOOLS_BINARIES=" $DRIVERS_TOOLS /.bin"
2018MONGODB_BINARIES=" $DRIVERS_TOOLS /mongodb/bin"
2119
22- # On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME.
20+ # On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME or
21+ # have binaries shared across tasks, so use a TMPDIR. On non-CI hosts
22+ # (spawn hosts, VMs such as GCP/Azure, and local dev), use the conventional
23+ # ~/.local/bin which tools on the PATH (or the shell rc) can find.
2324if [ " ${CI:- } " == " true" ]; then
24- PYMONGO_BIN_DIR=${DRIVERS_TOOLS_BINARIES:- }
25- # We want to use a path that's already on PATH on spawn hosts.
25+ PYMONGO_BIN_DIR=" ${TMPDIR:-/ tmp} " /pymongo_bin
2626else
27- PYMONGO_BIN_DIR=$HOME /cli_bin
27+ PYMONGO_BIN_DIR=$HOME /.local/bin
2828fi
2929
30- PATH_EXT=" $MONGODB_BINARIES :$DRIVERS_TOOLS_BINARIES :$PYMONGO_BIN_DIR :\$ PATH"
30+ # Cygwin spelling for bash PATH entries; PYMONGO_BIN_DIR itself is converted
31+ # to native form below for consumers like uv.
32+ if [ " Windows_NT" = " ${OS:- } " ]; then
33+ PYMONGO_BIN_DIR_POSIX=" $( cygpath -u " $PYMONGO_BIN_DIR " ) "
34+ else
35+ PYMONGO_BIN_DIR_POSIX=" $PYMONGO_BIN_DIR "
36+ fi
37+
38+ # Add the latest MongoDB toolchain bin dir to PATH if it exists, so that hosts
39+ # with an old system Python (e.g. RHEL8's 3.6) still get a modern interpreter
40+ # for tool installs like `uv tool install rust-just`. It goes after
41+ # PYMONGO_BIN_DIR so the pinned uv (installed there by setup-uv.py) takes
42+ # precedence over the toolchain's uv.
43+ if [ " Windows_NT" = " ${OS:- } " ]; then
44+ _toolchain_bin=" /cygdrive/c/Python/Current/Scripts"
45+ elif [ " $( uname -s) " == " Darwin" ]; then
46+ _toolchain_bin=" /Library/Frameworks/Python.Framework/Versions/Current/bin"
47+ else
48+ _toolchain_bin=" /opt/python/Current/bin"
49+ fi
50+ if [ -d " $_toolchain_bin " ]; then
51+ PATH_EXT=" $MONGODB_BINARIES :$PYMONGO_BIN_DIR_POSIX :$_toolchain_bin :$DRIVERS_TOOLS_BINARIES :\$ PATH"
52+ else
53+ PATH_EXT=" $MONGODB_BINARIES :$PYMONGO_BIN_DIR_POSIX :$DRIVERS_TOOLS_BINARIES :\$ PATH"
54+ fi
3155
3256# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
3357if [ " Windows_NT" = " ${OS:- } " ]; then # Magic variable in cygwin
3458 DRIVERS_TOOLS=$( cygpath -m $DRIVERS_TOOLS )
3559 PROJECT_DIRECTORY=$( cygpath -m $PROJECT_DIRECTORY )
3660 CARGO_HOME=$( cygpath -m $CARGO_HOME )
37- UV_TOOL_DIR=$( cygpath -m " $UV_TOOL_DIR " )
38- UV_CACHE_DIR=$( cygpath -m " $UV_CACHE_DIR " )
3961 DRIVERS_TOOLS_BINARIES=$( cygpath -m " $DRIVERS_TOOLS_BINARIES " )
4062 MONGODB_BINARIES=$( cygpath -m " $MONGODB_BINARIES " )
63+ # Native form, uniform with the paths above, for consumers like uv.
4164 PYMONGO_BIN_DIR=$( cygpath -m " $PYMONGO_BIN_DIR " )
4265fi
4366
@@ -62,10 +85,8 @@ export DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS_BINARIES"
6285export PROJECT_DIRECTORY="$PROJECT_DIRECTORY "
6386
6487export CARGO_HOME="$CARGO_HOME "
65- export UV_TOOL_DIR="$UV_TOOL_DIR "
66- export UV_CACHE_DIR="$UV_CACHE_DIR "
67- export UV_TOOL_BIN_DIR="$DRIVERS_TOOLS_BINARIES "
6888export PYMONGO_BIN_DIR="$PYMONGO_BIN_DIR "
89+ export PYMONGO_BIN_DIR_POSIX="$PYMONGO_BIN_DIR_POSIX "
6990export PATH="$PATH_EXT "
7091# shellcheck disable=SC2154
7192export PROJECT="${project:- mongo-python-driver} "
@@ -90,25 +111,3 @@ cat <<EOT > expansion.yml
90111DRIVERS_TOOLS: "$DRIVERS_TOOLS "
91112PROJECT_DIRECTORY: "$PROJECT_DIRECTORY "
92113EOT
93-
94- # If the toolchain is available, symlink binaries to the bin dir. This has to be done
95- # after drivers-tools is cloned, since we might be using its binary dir.
96- _bin_path=" "
97- if [ " Windows_NT" == " ${OS:- } " ]; then
98- _bin_path=" /cygdrive/c/Python/Current/Scripts"
99- elif [ " $( uname -s) " == " Darwin" ]; then
100- _bin_path=" /Library/Frameworks/Python.Framework/Versions/Current/bin"
101- else
102- _bin_path=" /opt/python/Current/bin"
103- fi
104- if [ -d " ${_bin_path} " ]; then
105- _suffix=" "
106- if [ " Windows_NT" == " ${OS:- } " ]; then
107- _suffix=" .exe"
108- fi
109- echo " Symlinking binaries from toolchain"
110- mkdir -p $PYMONGO_BIN_DIR
111- ln -s ${_bin_path} /just${_suffix} $PYMONGO_BIN_DIR /just${_suffix}
112- ln -s ${_bin_path} /uv${_suffix} $PYMONGO_BIN_DIR /uv${_suffix}
113- ln -s ${_bin_path} /uvx${_suffix} $PYMONGO_BIN_DIR /uvx${_suffix}
114- fi
0 commit comments