Skip to content

Commit 796706e

Browse files
committed
cleanup script
1 parent 9411c3d commit 796706e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

plugins/pip/venvShellHook.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set -eu
12
STATE_FILE="$DEVBOX_PROJECT_ROOT/.devbox/venv_check_completed"
23
echo $STATE_FILE
34

@@ -16,7 +17,6 @@ is_devbox_python() {
1617

1718
while true; do
1819
if [ ! -L "$python_path" ]; then
19-
echo $python_path
2020
# Not a symlink, we're done
2121
break
2222
fi
@@ -36,6 +36,8 @@ is_devbox_python() {
3636
break
3737
fi
3838
done
39+
40+
[[ $python_path == $DEVBOX_PACKAGES_DIR/* ]]
3941
}
4042

4143
# Function to check Python version
@@ -50,14 +52,13 @@ check_python_version() {
5052

5153
# Check if we've already run this script
5254
if [ -f "$STATE_FILE" ]; then
55+
# "We've already run this script. Exiting..."
5356
exit 0
5457
fi
5558

5659
# Check Python version
5760
if ! check_python_version; then
58-
echo "\n\033[1;33m========================================\033[0m"
5961
echo "\033[1;33mWARNING: Python version must be > 3.3 to create a virtual environment.\033[0m"
60-
echo "\033[1;33m========================================\033[0m"
6162
touch "$STATE_FILE"
6263
exit 1
6364
fi
@@ -66,9 +67,7 @@ fi
6667
if [ -d "$VENV_DIR" ]; then
6768
if is_valid_venv "$VENV_DIR"; then
6869
if ! is_devbox_python "$VENV_DIR"; then
69-
echo "\n\033[1;33m========================================\033[0m"
70-
echo "\033[1;33mWARNING: Existing virtual environment doesn't use Devbox Python.\033[0m"
71-
echo "\033[1;33m========================================\033[0m"
70+
echo "\033[1;33mWARNING: Virtual environment at $VENV_DIR doesn't use Devbox Python.\033[0m"
7271
echo "Virtual environment: $VENV_DIR"
7372
read -p "Do you want to overwrite it? (y/n) " -n 1 -r
7473
echo
@@ -77,7 +76,7 @@ if [ -d "$VENV_DIR" ]; then
7776
rm -rf "$VENV_DIR"
7877
python3 -m venv "$VENV_DIR"
7978
else
80-
echo "Operation cancelled."
79+
echo "Using existing virtual environment. We recommend changing \$VENV_DIR"
8180
touch "$STATE_FILE"
8281
exit 1
8382
fi

0 commit comments

Comments
 (0)