7a10fafb0b41ef6b0d691119a78587facfe75dfc

Author
Nick Cross <ncross@redhat.com>
Committer
Michael Aquilina <michaelaquilina@gmail.com>
Date

Message

Install by default in editable/development mode.

Fixes #86.

Diff

 1diff --git a/README.rst b/README.rst
 2index cbf37438d4a0fe358bab304297021e87dc053996..dc199e379782bbb7d5b250bd934384101ab95f53 100644
 3--- a/README.rst
 4+++ b/README.rst
 5@@ -296,6 +296,13 @@ the same location that the ``virtualenvwrapper`` package uses.
 6 If you wish to change this to another location, simply set the value of the
 7 environment variable ``AUTOSWITCH_VIRTUAL_ENV_DIR``.
 8 
 9+**Customising pip install invocation**
10+
11+By default it will invoke pip install in editable (i.e. development) mode. See
12+`here <http://codumentary.blogspot.com/2014/11/python-tip-of-year-pip-install-editable.html/>`__
13+and `here <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs/>`__ for
14+further information. To change this set ``AUTOSWITCH_PIPINSTALL`` to ``FULL``.
15+
16 Security Warnings
17 -----------------
18 
19diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
20index 7f99c0d5db26a374609991ef1e5b2155ec0a11c9..813f6e1e027b61385cad2a26ed21d79c85e03963 100644
21--- a/autoswitch_virtualenv.plugin.zsh
22+++ b/autoswitch_virtualenv.plugin.zsh
23@@ -227,7 +227,12 @@ function install_requirements() {
24         read ans
25 
26         if [[ "$ans" = "y" || "$ans" = "Y" ]]; then
27-            pip install .
28+            if [[ "$AUTOSWITCH_PIPINSTALL" = "FULL" ]]
29+            then
30+                pip install .
31+            else
32+                pip install -e .
33+            fi
34         fi
35     fi
36 
37diff --git a/tests/test_install_requirements.zunit b/tests/test_install_requirements.zunit
38index a0368d14488252b55deb337bec3e0f9e777babeb..c18b66254a114d8215607b0968d1986daf94dea7 100644
39--- a/tests/test_install_requirements.zunit
40+++ b/tests/test_install_requirements.zunit
41@@ -100,7 +100,7 @@
42 
43     assert $status equals 0
44     assert "$lines[1]" same_as "Found a \e[35msetup.py\e[0m file. Install dependencies? [y/N]: y"
45-    assert "$lines[2]" same_as "pip install ."
46+    assert "$lines[2]" same_as "pip install -e ."
47 }
48 
49 @test 'install_requirements - installs recursive *requirements.txt' {
50@@ -125,3 +125,20 @@
51     assert "$lines[5]" same_as "pip install -r subdir/dev-requirements.txt"
52     assert "$lines[6]" same_as "pytest"
53 }
54+
55+@test 'install_requirements - installs setup.py' {
56+    touch "setup.py"
57+    echo "django" > requirements.txt
58+
59+    # mock pip to make it testable
60+    function pip {
61+        echo "pip $@"
62+    }
63+    local AUTOSWITCH_PIPINSTALL="FULL"
64+
65+    run install_requirements
66+
67+    assert $status equals 0
68+    assert "$lines[1]" same_as "Found a \e[35msetup.py\e[0m file. Install dependencies? [y/N]: y"
69+    assert "$lines[2]" same_as "pip install ."
70+}