diff --git a/plugins/pip.json b/plugins/pip.json index a55632cba8b..9cf392de599 100644 --- a/plugins/pip.json +++ b/plugins/pip.json @@ -3,7 +3,8 @@ "version": "0.0.2", "description": "This plugin adds a script for automatically creating a virtual environment using `venv` for python3 projects, so you can install packages with pip as normal.\nTo activate the environment, run `. $VENV_DIR/bin/activate` or add it to the init_hook of your devbox.json\nTo change where your virtual environment is created, modify the $VENV_DIR environment variable in your init_hook", "env": { - "VENV_DIR": "{{ .Virtenv }}/.venv" + "VENV_DIR": "{{ .Virtenv }}/.venv", + "UV_PYTHON": "{{ .DevboxProjectRoot }}/.devbox/nix/profile/default/bin/python" }, "create_files": { "{{ .Virtenv }}/bin/venvShellHook.sh": "pip/venvShellHook.sh" diff --git a/plugins/pip/venvShellHook.sh b/plugins/pip/venvShellHook.sh index bb2341be662..af0778b3c3c 100755 --- a/plugins/pip/venvShellHook.sh +++ b/plugins/pip/venvShellHook.sh @@ -15,12 +15,6 @@ create_venv() { echo "*\n.*" >> "$VENV_DIR/.gitignore" } -# Check if we've already run this script -if [ -f "$STATE_FILE" ]; then - # "We've already run this script. Exiting..." - exit 0 -fi - # Check that Python version supports venv if ! python -c 'import venv' 1> /dev/null 2> /dev/null; then echo "\033[1;33mWARNING: Python version must be > 3.3 to create a virtual environment.\033[0m" @@ -31,6 +25,11 @@ fi # Check if the directory exists if [ -d "$VENV_DIR" ]; then if is_valid_venv "$VENV_DIR"; then + # Check if we've already run this script + if [ -f "$STATE_FILE" ]; then + # "We've already run this script. Exiting..." + exit 0 + fi if ! is_devbox_venv "$VENV_DIR"; then echo "\033[1;33mWARNING: Virtual environment at $VENV_DIR doesn't use Devbox Python.\033[0m" read -p "Do you want to overwrite it? (y/n) " -n 1 -r