Commits

Doug Hellmann committed 465a250

set log dir and hook dir variables after WORKON_HOME is set; fixes #94

  • Participants
  • Parent commits 5e22c0f

Comments (0)

Files changed (4)

docs/en/history.rst

 Release History
 ===============
 
+2.7.1
+
+  - When testing for WORKON_HOME during startup, dereference any
+    symlink to make sure it is a directory.
+  - Set VIRTUALENVWRAPPER_HOOK_DIR and VIRTUALENV_WRAPPER_LOG DIR in
+    virtualenvwrapper_initialize after WORKON_HOME is set
+    (:bbissue:`94`).
+  - Update the :ref:`install-basic` instructions to be more explicit
+    about needing to install virtualenvwrapper globally (or at least
+    outside of a virtualenv).
+
 2.7
 
   - Fix problem with space in WORKON_HOME path (:bbissue:`79`).

docs/en/install.rst

 
 virtualenvwrapper is tested under Python 2.4 - 2.7.
 
+.. _install-basic:
+
 Basic Installation
 ==================
 

tests/test_log_dir.sh

 
 export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
-oneTimeSetUp() {
-    rm -rf "$WORKON_HOME"
-    mkdir -p "$WORKON_HOME"
-    mkdir -p "$WORKON_HOME/hooks"
+setUp () {
+    echo
 }
 
-oneTimeTearDown() {
-    rm -rf "$WORKON_HOME"
-}
-
-setUp () {
-    echo
-    rm -f "$test_dir/catch_output"
-    rm -f "$WORKON_HOME/hooks/*"
-}
-
-test_virtualenvwrapper_initialize() {
+test_set_by_user() {
     export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs"
     mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR"
     source "$test_dir/../virtualenvwrapper.sh"
     assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]"
 }
 
+test_not_set_by_user() {
+    unset WORKON_HOME
+    unset VIRTUALENVWRAPPER_LOG_DIR
+    unset VIRTUALENVWRAPPER_HOOK_DIR
+    source "$test_dir/../virtualenvwrapper.sh"
+    assertSame "$WORKON_HOME" "$VIRTUALENVWRAPPER_LOG_DIR"
+}
+
 . "$test_dir/shunit2"

virtualenvwrapper.sh

     VIRTUALENVWRAPPER_VIRTUALENV="virtualenv"
 fi
 
-# Set the location of the hook scripts
-if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ]
-then
-    export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
-fi
-
-# Set the location of the hook script logs
-if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ]
-then
-    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
-fi
-
 virtualenvwrapper_derive_workon_home() {
     typeset workon_home_dir="$WORKON_HOME"
 
 # and maybe other things rely on the dir existing before that happens.
 virtualenvwrapper_verify_workon_home () {
     RC=0
-    if [ ! -d "$WORKON_HOME" ]
+    if [ ! -d "$WORKON_HOME/" ]
     then
         if [ "$1" != "-q" ]
         then
 # Set up virtualenvwrapper properly
 virtualenvwrapper_initialize () {
     export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)"
+
     virtualenvwrapper_verify_workon_home -q || return 1
+
+    # Set the location of the hook scripts
+    if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ]
+    then
+        export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
+    fi
+
+    # Set the location of the hook script logs
+    if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ]
+    then
+        export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
+    fi
+
     virtualenvwrapper_run_hook "initialize"
     if [ $? -ne 0 ]
     then