Skip to content

Commit 132b2b0

Browse files
committed
Replace realpath with a more portable way of converting a relative path to an absolute path
1 parent eb51a32 commit 132b2b0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

virtualenvwrapper.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ function virtualenvwrapper_expandpath {
110110
fi
111111
}
112112

113+
function virtualenvwrapper_absolutepath {
114+
if [ "$1" = "" ]; then
115+
return 1
116+
else
117+
"$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$1\")+'\n')"
118+
return 0
119+
fi
120+
}
121+
113122
function virtualenvwrapper_derive_workon_home {
114123
typeset workon_home_dir="$WORKON_HOME"
115124

@@ -405,7 +414,7 @@ function mkvirtualenv {
405414
-p|--python)
406415
i=$(( $i + 1 ));
407416
interpreter="${in_args[$i]}";
408-
interpreter=$(realpath "$interpreter");;
417+
interpreter=$(virtualenvwrapper_absolutepath "$interpreter");;
409418
-r)
410419
i=$(( $i + 1 ));
411420
requirements="${in_args[$i]}";
@@ -749,7 +758,7 @@ function add2virtualenv {
749758

750759
for pydir in "$@"
751760
do
752-
absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$pydir\")+'\n')")
761+
absolute_path=$(virtualenvwrapper_absolutepath "$pydir")
753762
if [ "$absolute_path" != "$pydir" ]
754763
then
755764
echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2

0 commit comments

Comments
 (0)