5151 export WORKON_HOME=" $HOME /.virtualenvs"
5252fi
5353
54+ # Locate the global Python where virtualenvwrapper is installed.
55+ VIRTUALENVWRAPPER_PYTHON=" $( which python) "
56+
5457# Normalize the directory name in case it includes
5558# relative path components.
56- WORKON_HOME=$( python -c " import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\" $WORKON_HOME \" )))" )
59+ WORKON_HOME=$( " $VIRTUALENVWRAPPER_PYTHON " -c " import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\" $WORKON_HOME \" )))" )
5760export WORKON_HOME
5861
5962# Verify that the WORKON_HOME directory exists
@@ -66,17 +69,19 @@ function virtualenvwrapper_verify_workon_home () {
6669 return 0
6770}
6871
72+ HOOK_VERBOSE_OPTION=" -v"
6973
7074# Run a hook script in the current shell
7175function virtualenvwrapper_source_hook () {
72- python -m virtualenvwrapper.hook_loader --source " ${1} _source" >> $TMPDIR /$$ .hook
76+ " $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \
77+ --source " ${1} _source" >> $TMPDIR /$$ .hook
7378 source $TMPDIR /$$ .hook
7479 rm -f $TMPDIR /$$ .hook
7580}
7681
7782# Run a hook script in its own shell
7883function virtualenvwrapper_run_hook () {
79- python -m virtualenvwrapper.hook_loader " $@ "
84+ " $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION " $@ "
8085}
8186
8287# Set up virtualenvwrapper properly
@@ -136,19 +141,16 @@ function mkvirtualenv () {
136141 virtualenvwrapper_verify_virtualenv || return 1
137142 (cd " $WORKON_HOME " &&
138143 virtualenv " $@ " &&
139- virtualenvwrapper_run_hook " ./premkvirtualenv " " $envname "
144+ virtualenvwrapper_run_hook " pre_mkvirtualenv " " $envname "
140145 )
141146 # If they passed a help option or got an error from virtualenv,
142147 # the environment won't exist. Use that to tell whether
143148 # we should switch to the environment and run the hook.
144149 [ ! -d " $WORKON_HOME /$envname " ] && return 0
145- # Create stubs for the environment-specific hook scripts.
146- virtualenvwrapper_make_hook " $WORKON_HOME /$envname /bin/postactivate" " This hook is sourced after the virtualenv is activated."
147- virtualenvwrapper_make_hook " $WORKON_HOME /$envname /bin/predeactivate" " This hook is sourced before the virtualenv is deactivated."
148- virtualenvwrapper_make_hook " $WORKON_HOME /$envname /bin/postdeactivate" " This hook is sourced after the virtualenv is deactivated."
149150 # Now activate the new environment
150151 workon " $envname "
151- virtualenvwrapper_source_hook " $WORKON_HOME /postmkvirtualenv"
152+ virtualenvwrapper_run_hook " post_mkvirtualenv"
153+ virtualenvwrapper_source_hook " post_mkvirtualenv"
152154}
153155
154156# Remove an environment, in the WORKON_HOME.
0 commit comments