Skip to content

Commit e41f4f1

Browse files
committed
Fix --python switch for virtualenv.
When using mkvirtualenv and pass in the --python (or the shorter -p version), virtualenv will fail to find the correct interpreter path if that path is relative to the working dir, because virtualenvwrapper switches the current directory right before calling virtualenv.
1 parent ae236e2 commit e41f4f1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

virtualenvwrapper.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ function mkvirtualenv {
402402
-i)
403403
i=$(( $i + 1 ));
404404
packages="$packages ${in_args[$i]}";;
405+
-p|--python)
406+
i=$(( $i + 1 ));
407+
interpreter="${in_args[$i]}";
408+
interpreter=$(realpath "$interpreter");;
405409
-r)
406410
i=$(( $i + 1 ));
407411
requirements="${in_args[$i]}";
@@ -417,6 +421,11 @@ function mkvirtualenv {
417421
i=$(( $i + 1 ))
418422
done
419423

424+
if [ ! -z $interpreter ]
425+
then
426+
out_args=( "--python=$interpreter" ${out_args[@]} )
427+
fi;
428+
420429
set -- "${out_args[@]}"
421430

422431
eval "envname=\$$#"

0 commit comments

Comments
 (0)