Commits

Doug Hellmann committed 8af191b

fix for ticket #14: relative paths don't work with add2virtualenv

Comments (0)

Files changed (4)

docsource/history.rst

 Release History
 ===============
 
+1.19
+
+  - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix.
+
 1.18.1
 
   - Incorporate patch from Sascha Brossmann to fix a issue #15. Directory normalization was causing ``WORKON_HOME`` to appear to be a missing directory if there were control characters in the output of ``pwd``.
 
 # What project are we building?
 PROJECT = 'virtualenvwrapper'
-VERSION = '1.18.1'
+VERSION = '1.19'
 os.environ['VERSION'] = VERSION
 
 # Read the long description to give to setup
     WORKON_HOME="$save_home"
 }
 
+test_add2virtualenv () {
+    mkvirtualenv "pathtest"
+    add2virtualenv "/full/path"
+    cdsitepackages
+    path_file="./virtualenv_path_extensions.pth"
+    assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file"
+    cd -
+}
+
+test_add2virtualenv_relative () {
+    mkvirtualenv "pathtest"
+    parent_dir=$(dirname $(pwd))
+    base_dir=$(basename $(pwd))
+    add2virtualenv "../$base_dir"
+    cdsitepackages
+    path_file="./virtualenv_path_extensions.pth"
+    assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file"
+    cd - >/dev/null 2>&1
+}
+
 . "$test_dir/shunit2"

virtualenvwrapper_bashrc

     touch "$path_file"
     for pydir in "$@"
     do
-        echo "$pydir" >> "$path_file"
+        absolute_path=$(python -c "import os; print os.path.abspath(\"$pydir\")")
+        if [ "$absolute_path" != "$pydir" ]
+        then
+            echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
+        fi
+        echo "$absolute_path" >> "$path_file"
     done
     return 0
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.