@@ -8,9 +8,7 @@ if [ -z "$BASH" ]; then
88 return 1
99fi
1010
11- if [ -z " ${1:- } " ]; then
12- echo " Must give a target directory!"
13- fi
11+ TARGET_DIR=" ${1:? " must give a target directory!" } "
1412
1513SCRIPT_DIR=$( dirname ${BASH_SOURCE[0]} )
1614. $SCRIPT_DIR /handle-paths.sh
@@ -27,33 +25,58 @@ if [ "${DOCKER_RUNNING:-}" == "true" ]; then
2725 UV_TOOL_DIR=$_root_dir /uv-tool
2826fi
2927
30- . ./venv-utils.sh
28+ # If uv is not on path, try see if it is available from the Python toolchain.
29+ if ! command -v uv > /dev/null; then
30+ export PATH
31+ case " ${OSTYPE:? } " in
32+ cygwin)
33+ PATH=" /cygdrive/c/Python/Current:${PATH:- } "
34+ ;;
35+ darwin* )
36+ PATH=" /Library/Frameworks/Python.Framework/Versions/Current/bin:${PATH:- } "
37+ ;;
38+ * )
39+ PATH=" /opt/python/Current/bin:${PATH:- } "
40+ ;;
41+ esac
42+ fi
3143
32- if [ ! -d $SCRIPT_DIR /venv ]; then
44+ if command -V uv 2> /dev/null; then
45+ # Ensure there is a venv available for backward compatibility.
46+ uv venv venv
47+ else
48+ # If uv is still not available, we need a venv.
49+ . ./venv-utils.sh
3350
34- . ./find-python3.sh
51+ # Create and activate `venv` via `venvcreate` or `venvactivate`.
52+ if [ ! -d " $SCRIPT_DIR /venv" ]; then
3553
36- echo " Ensuring python binary..."
37- PYTHON=$( ensure_python3 2> /dev/null)
38- echo " Ensuring python binary... done."
54+ . ./find-python3.sh
3955
40- echo " Creating virtual environment 'venv'..."
41- venvcreate " ${PYTHON:? } " venv
42- echo " Creating virtual environment 'venv'... done."
43- else
44- venvactivate venv
45- fi
56+ echo " Ensuring python binary..."
57+ PYTHON=" $( ensure_python3 2> /dev/null) "
58+ echo " Ensuring python binary... done."
4659
47- if ! command -v uv > /dev/null; then
60+ echo " Creating virtual environment 'venv'..."
61+ venvcreate " ${PYTHON:? } " venv
62+ echo " Creating virtual environment 'venv'... done."
63+ else
64+ venvactivate venv
65+ fi
66+
67+ # Install uv into the newly created venv.
4868 UV_UNMANAGED_INSTALL=1 python -m pip install -q --force-reinstall uv
69+
70+ # Ensure a working uv binary is present.
71+ command -V uv
4972fi
5073
51- command -V uv # Ensure a working uv binary is present .
74+ [[ -d venv ]] # venv should exist by this point .
5275
5376# Store paths to binaries for use outside of current working directory.
54- python_binary=" $( which python) "
77+ python_binary=" $( uv run --no-project python -c ' import sys;print(sys.executable) ' ) "
5578
56- pushd $1 > /dev/null
79+ pushd " $TARGET_DIR " > /dev/null
5780
5881# Add support for MongoDB 3.6, which was dropped in pymongo 4.11.
5982EXTRA_ARGS=" "
6689if [ " Windows_NT" == " ${OS:- } " ]; then
6790 TMP_DIR=$( cygpath -m " $( mktemp -d) " )
6891 PATH=" $SCRIPT_DIR /venv/Scripts:$PATH "
69- UV_TOOL_BIN_DIR=${TMP_DIR} uv tool install ${EXTRA_ARGS} --force --editable .
92+ UV_TOOL_BIN_DIR=${TMP_DIR} uv tool install ${EXTRA_ARGS} --with certifi -- force --editable .
7093 filenames=$( ls ${TMP_DIR} )
7194 for filename in $filenames ; do
7295 mv $TMP_DIR /$filename " $1 /${filename// .exe/ } "
7396 done
7497 rm -rf $TMP_DIR
7598else
76- UV_TOOL_BIN_DIR=$( pwd) uv tool install -q ${EXTRA_ARGS} --python " ${python_binary} " --force --editable .
99+ UV_TOOL_BIN_DIR=$( pwd) uv tool install -q ${EXTRA_ARGS} --python " ${python_binary} " --with certifi -- force --editable .
77100fi
78101
79102popd > /dev/null
0 commit comments