Skip to content

Commit 9ba780c

Browse files
authored
PYTHON-4861 Ensure hatch is isolated in Evergreen (mongodb#1923)
1 parent 3c5e71a commit 9ba780c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.evergreen/hatch.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@ if [ -n "$SKIP_HATCH" ]; then
1818
run_hatch() {
1919
bash ./.evergreen/run-tests.sh
2020
}
21-
elif $PYTHON_BINARY -m hatch --version; then
22-
run_hatch() {
23-
$PYTHON_BINARY -m hatch run "$@"
24-
}
25-
else # No toolchain hatch present, set up virtualenv before installing hatch
21+
else # Set up virtualenv before installing hatch
2622
# Use a random venv name because the encryption tasks run this script multiple times in the same run.
2723
ENV_NAME=hatchenv-$RANDOM
2824
createvirtualenv "$PYTHON_BINARY" $ENV_NAME
2925
# shellcheck disable=SC2064
3026
trap "deactivate; rm -rf $ENV_NAME" EXIT HUP
3127
python -m pip install -q hatch
28+
29+
# Ensure hatch does not write to user or global locations.
30+
touch hatch_config.toml
31+
HATCH_CONFIG=$(pwd)/hatch_config.toml
32+
export HATCH_CONFIG
33+
hatch config restore
34+
hatch config set dirs.data ".hatch/data"
35+
hatch config set dirs.cache ".hatch/cache"
36+
3237
run_hatch() {
3338
python -m hatch run "$@"
3439
}

0 commit comments

Comments
 (0)