Skip to content

Commit 48320dc

Browse files
authored
Polish create-venv.sh (#274)
* Quotes everywhere * Handle Windows special case * Use "--clear" when creating the venv: this way running the action twice in the same environment is not a problem Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent b3dd847 commit 48320dc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

setup/create-venv.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ fi
1414
ENV=$1
1515

1616
BOOTSTRAP_ENV=$(mktemp -d)
17-
python3 -m venv --clear $BOOTSTRAP_ENV
18-
. $BOOTSTRAP_ENV/bin/activate && pip install uv && uv venv $ENV && VIRTUAL_ENV=$ENV uv pip install uv
19-
touch $ENV/bootstrap
20-
rm -r $BOOTSTRAP_ENV
17+
python3 -m venv --clear "$BOOTSTRAP_ENV"
18+
19+
# Annoying: Windows venvs use a different structure, for unknown reasons.
20+
if [ -d "$BOOTSTRAP_ENV/bin" ]; then
21+
BIN="$BOOTSTRAP_ENV/bin"
22+
else
23+
BIN="$BOOTSTRAP_ENV/Scripts"
24+
fi
25+
26+
27+
. "$BIN/activate" && pip install uv && uv venv --clear $ENV && VIRTUAL_ENV="$ENV" uv pip install uv
28+
touch "$ENV/bootstrap"
29+
rm -r "$BOOTSTRAP_ENV"

0 commit comments

Comments
 (0)