Skip to content

Commit 05aff40

Browse files
committed
Merged in barberj/vew/fix_installing_requirements_after_cd (pull request #21)
2 parents 3ca7ba1 + 5b35a17 commit 05aff40

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

tests/test_expandpath.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
test_dir=$(cd $(dirname $0) && pwd)
4+
source "$test_dir/setup.sh"
5+
TMP_WORKON_HOME="$WORKON_HOME"
6+
7+
oneTimeSetUp() {
8+
source "$test_dir/../virtualenvwrapper.sh"
9+
echo $PYTHONPATH
10+
}
11+
12+
oneTimeTearDown() {
13+
return 0
14+
}
15+
16+
test_tilde() {
17+
assertSame "$HOME" "$(virtualenvwrapper_expandpath ~)"
18+
}
19+
20+
test_vars() {
21+
assertSame "$HOME" "$(virtualenvwrapper_expandpath '$HOME')"
22+
}
23+
24+
test_tilde_vars() {
25+
assertSame "$HOME" "$(virtualenvwrapper_expandpath '~$USER')"
26+
}
27+
28+
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ then
7272
export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project"
7373
fi
7474

75+
function virtualenvwrapper_expandpath {
76+
if [ "$1" = "" ]; then
77+
return 1
78+
else
79+
"$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.realpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')"
80+
return 0
81+
fi
82+
}
83+
7584
function virtualenvwrapper_derive_workon_home {
7685
typeset workon_home_dir="$WORKON_HOME"
7786

@@ -99,7 +108,7 @@ function virtualenvwrapper_derive_workon_home {
99108
# - Removing extra slashes (e.g., when TMPDIR ends in a slash)
100109
# - Expanding variables (e.g., $foo)
101110
# - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur)
102-
workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))+'\n')")
111+
workon_home_dir=$(virtualenvwrapper_expandpath "$workon_home_dir")
103112
fi
104113

105114
echo "$workon_home_dir"
@@ -344,7 +353,8 @@ function mkvirtualenv {
344353
packages="$packages ${in_args[$i]}";;
345354
-r)
346355
i=$(( $i + 1 ));
347-
requirements="${in_args[$i]}";;
356+
requirements="${in_args[$i]}";
357+
requirements=$(virtualenvwrapper_expandpath "$requirements");;
348358
*)
349359
if [ ${#out_args} -gt 0 ]
350360
then

0 commit comments

Comments
 (0)