Skip to content

Commit 552b77f

Browse files
committed
fix for ticket #14: relative paths don't work with add2virtualenv
1 parent 945bd4b commit 552b77f

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

docsource/history.rst

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Release History
33
===============
44

5+
1.19
6+
7+
- Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix.
8+
59
1.18.1
610

711
- 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``.

pavement.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# What project are we building?
2929
PROJECT = 'virtualenvwrapper'
30-
VERSION = '1.18.1'
30+
VERSION = '1.19'
3131
os.environ['VERSION'] = VERSION
3232

3333
# Read the long description to give to setup

tests/test.sh

+20
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,24 @@ test_missing_workon_home () {
151151
WORKON_HOME="$save_home"
152152
}
153153

154+
test_add2virtualenv () {
155+
mkvirtualenv "pathtest"
156+
add2virtualenv "/full/path"
157+
cdsitepackages
158+
path_file="./virtualenv_path_extensions.pth"
159+
assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file"
160+
cd -
161+
}
162+
163+
test_add2virtualenv_relative () {
164+
mkvirtualenv "pathtest"
165+
parent_dir=$(dirname $(pwd))
166+
base_dir=$(basename $(pwd))
167+
add2virtualenv "../$base_dir"
168+
cdsitepackages
169+
path_file="./virtualenv_path_extensions.pth"
170+
assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file"
171+
cd - >/dev/null 2>&1
172+
}
173+
154174
. "$test_dir/shunit2"

virtualenvwrapper_bashrc

+6-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,12 @@ function add2virtualenv () {
261261
touch "$path_file"
262262
for pydir in "$@"
263263
do
264-
echo "$pydir" >> "$path_file"
264+
absolute_path=$(python -c "import os; print os.path.abspath(\"$pydir\")")
265+
if [ "$absolute_path" != "$pydir" ]
266+
then
267+
echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
268+
fi
269+
echo "$absolute_path" >> "$path_file"
265270
done
266271
return 0
267272
}

0 commit comments

Comments
 (0)