Skip to content

Commit 79e5d60

Browse files
authored
PYTHON-5268 Fix handling of PYTHON_BINARY (#2264)
1 parent bf0aa56 commit 79e5d60

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

.evergreen/scripts/install-dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function _pip_install() {
3939

4040

4141
# Ensure just is installed.
42-
if ! command -v just 2>/dev/null; then
42+
if ! command -v just >/dev/null 2>&1; then
4343
# On most systems we can install directly.
4444
_TARGET=""
4545
if [ "Windows_NT" = "${OS:-}" ]; then
@@ -54,7 +54,7 @@ if ! command -v just 2>/dev/null; then
5454
fi
5555

5656
# Install uv.
57-
if ! command -v uv 2>/dev/null; then
57+
if ! command -v uv >/dev/null 2>&1; then
5858
echo "Installing uv..."
5959
# On most systems we can install directly.
6060
curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="$_BIN_DIR" INSTALLER_NO_MODIFY_PATH=1 sh || {

.evergreen/scripts/setup-dev-env.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pushd $ROOT > /dev/null
1111
if [ -f $HERE/env.sh ]; then
1212
. $HERE/env.sh
1313
fi
14-
# PYTHON_BINARY may be defined in test-env.sh.
14+
# PYTHON_BINARY or PYTHON_VERSION may be defined in test-env.sh.
1515
if [ -f $HERE/test-env.sh ]; then
1616
. $HERE/test-env.sh
1717
fi
@@ -21,7 +21,6 @@ bash $HERE/install-dependencies.sh
2121

2222
# Get the appropriate UV_PYTHON.
2323
. $ROOT/.evergreen/utils.sh
24-
set -x
2524

2625
if [ -z "${PYTHON_BINARY:-}" ]; then
2726
if [ -n "${PYTHON_VERSION:-}" ]; then
@@ -31,7 +30,6 @@ if [ -z "${PYTHON_BINARY:-}" ]; then
3130
fi
3231
fi
3332
export UV_PYTHON=${PYTHON_BINARY}
34-
echo "export UV_PYTHON=$UV_PYTHON" >> $HERE/env.sh
3533
echo "Using python $UV_PYTHON"
3634

3735
# Add the default install path to the path if needed.

.evergreen/scripts/setup_tests.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
)
2727

2828
# Passthrough environment variables.
29-
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION", "DEBUG_LOG"]
29+
PASS_THROUGH_ENV = [
30+
"GREEN_FRAMEWORK",
31+
"NO_EXT",
32+
"MONGODB_API_VERSION",
33+
"DEBUG_LOG",
34+
"PYTHON_BINARY",
35+
"PYTHON_VERSION",
36+
]
3037

3138
# Map the test name to test extra.
3239
EXTRAS_MAP = {
@@ -164,8 +171,8 @@ def handle_test_env() -> None:
164171

165172
# Handle pass through env vars.
166173
for var in PASS_THROUGH_ENV:
167-
if is_set(var) or getattr(opts, var.lower()):
168-
write_env(var, os.environ.get(var, getattr(opts, var.lower())))
174+
if is_set(var) or getattr(opts, var.lower(), ""):
175+
write_env(var, os.environ.get(var, getattr(opts, var.lower(), "")))
169176

170177
if extra := EXTRAS_MAP.get(test_name, ""):
171178
UV_ARGS.append(f"--extra {extra}")

0 commit comments

Comments
 (0)