diff --git a/docsource/history.rst b/docsource/history.rst index 5a7d8de..5380279 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,10 @@ 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``. diff --git a/pavement.py b/pavement.py index 2ef46d3..4313114 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # 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 diff --git a/tests/test.sh b/tests/test.sh index d364368..41d1b9f 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -151,4 +151,24 @@ test_missing_workon_home () { 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" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index fcf7741..dd2df99 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -261,7 +261,12 @@ function add2virtualenv () { 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 }