Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index f01a730b8596473dc8c91f22b7be396db19bf06e..c692d0b34a9afefe6f985914bfb361b73c4fc885 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -114,7 +114,7 @@ function check_venv()
6 else
7 SWITCH_TO="$(<"$venv_path")"
8 fi
9- elif [[ -f "$PWD/requirements.txt" ]]; then
10+ elif [[ -f "$PWD/requirements.txt" || -f "$PWD/setup.py" ]]; then
11 printf "Python project detected. "
12 printf "Run ${PURPLE}mkvenv${NORMAL} to setup autoswitching\n"
13 fi
14@@ -194,6 +194,17 @@ function mkvenv()
15
16 function install_requirements() {
17 setopt nullglob
18+ if [[ -f "$PWD/setup.py" ]]; then
19+ printf "Found a ${PURPLE}setup.py${NORMAL} file. Install dependencies?: "
20+ read ans
21+
22+ if [[ "$ans" = "y" || "$ans" = "Y" ]]; then
23+ pip install .
24+ # We probably don't want to ALSO install requirements.txt
25+ return
26+ fi
27+ fi
28+
29 for requirements in *requirements.txt
30 do
31 printf "Found a ${PURPLE}%s${NORMAL} file. Install? [y/N]: " "$requirements"
32diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
33index cab07d2dd4be4a56c416c2677685454327ea6eaf..a90d37a38438514cb1096c322cf20b073857b78d 100644
34--- a/tests/test_check_venv.zunit
35+++ b/tests/test_check_venv.zunit
36@@ -25,7 +25,7 @@
37 rm -rf Pipfile
38 }
39
40-@test 'check_venv - Displays message on project detection' {
41+@test 'check_venv - Displays message on project detection (requirements.txt)' {
42 PWD="$TARGET"
43 touch "$TARGET/requirements.txt"
44
45@@ -35,6 +35,26 @@
46 assert "$output" same_as "Python project detected. Run \e[35mmkvenv\e[0m to setup autoswitching"
47 }
48
49+@test 'check_venv - Displays message on project detection (setup.py)' {
50+ PWD="$TARGET"
51+ touch "$TARGET/setup.py"
52+
53+ run check_venv
54+
55+ assert $status equals 0
56+ assert "$output" same_as "Python project detected. Run \e[35mmkvenv\e[0m to setup autoswitching"
57+}
58+
59+@test 'check_venv - Displays message on project detection (setup.py + requirements.txt)' {
60+ PWD="$TARGET"
61+ touch "$TARGET/setup.py"
62+ touch "$TARGET/requirements.txt"
63+
64+ run check_venv
65+
66+ assert $status equals 0
67+ assert "$output" same_as "Python project detected. Run \e[35mmkvenv\e[0m to setup autoswitching"
68+}
69
70 @test 'check_venv - Security warning for weak writeable by group permissions' {
71 PWD="$TARGET"