Merge pull request #139 from Qdulf/138-poetry-in-project-fix
Poetry in project issue
Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 071a2d617083c6ebd4232ac53ef3fa52d3f4c5d6..648106c21ffdef4da431870467fa904d77aaaba9 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -142,17 +142,9 @@ function _check_path()
6 function _activate_poetry() {
7 # check if any environments exist before trying to activate
8 # if env list is empty, then no environment exists that can be activated
9- name="$(poetry env list | cut -d' ' -f1)"
10+ local name="$(poetry env list --full-path | cut -d' ' -f1)"
11 if [[ -n "$name" ]]; then
12- local venv_path
13- # Temporary work around until we figure out a better way to
14- # correctly determine the location of virtualenvs in poetry
15- if [[ "$(uname)" == "Darwin" ]]; then
16- venv_path="$HOME/Library/Caches/pypoetry/virtualenvs/$name"
17- else
18- venv_path="$HOME/.cache/pypoetry/virtualenvs/$name"
19- fi
20- _maybeworkon "$venv_path" "poetry"
21+ _maybeworkon "$name" "poetry"
22 return 0
23 fi
24 return 1
25diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
26index f514c969d23c270f22ec7349b1bddba287d3d38d..df9295283ba1800a43333e3079bdf88288099397 100644
27--- a/tests/test_check_venv.zunit
28+++ b/tests/test_check_venv.zunit
29@@ -176,9 +176,9 @@
30 PWD="$TARGET/sub-directory" # Should also work in subdirectories where poetry.lock is found
31 touch "$TARGET/poetry.lock"
3233- # Mimic "poetry env list"
34+ # Mimic "poetry env list --full-path"
35 function poetry {
36- echo "poetry-foo (activated)"
37+ echo "$HOME/.cache/pypoetry/virtualenvs/poetry-foo (Activated)"
38 }
3940 run check_venv