Skip to content

Commit 55ee2f7

Browse files
committed
set log dir and hook dir variables after WORKON_HOME is set; fixes #94
1 parent 5967013 commit 55ee2f7

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

docs/en/history.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
Release History
33
===============
44

5+
2.7.1
6+
7+
- When testing for WORKON_HOME during startup, dereference any
8+
symlink to make sure it is a directory.
9+
- Set VIRTUALENVWRAPPER_HOOK_DIR and VIRTUALENV_WRAPPER_LOG DIR in
10+
virtualenvwrapper_initialize after WORKON_HOME is set
11+
(:bbissue:`94`).
12+
- Update the :ref:`install-basic` instructions to be more explicit
13+
about needing to install virtualenvwrapper globally (or at least
14+
outside of a virtualenv).
15+
516
2.7
617

718
- Fix problem with space in WORKON_HOME path (:bbissue:`79`).

docs/en/install.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Python Versions
2323

2424
virtualenvwrapper is tested under Python 2.4 - 2.7.
2525

26+
.. _install-basic:
27+
2628
Basic Installation
2729
==================
2830

tests/test_log_dir.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,23 @@ test_dir=$(cd $(dirname $0) && pwd)
66

77
export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
88

9-
oneTimeSetUp() {
10-
rm -rf "$WORKON_HOME"
11-
mkdir -p "$WORKON_HOME"
12-
mkdir -p "$WORKON_HOME/hooks"
13-
}
14-
15-
oneTimeTearDown() {
16-
rm -rf "$WORKON_HOME"
17-
}
18-
199
setUp () {
2010
echo
21-
rm -f "$test_dir/catch_output"
22-
rm -f "$WORKON_HOME/hooks/*"
2311
}
2412

25-
test_virtualenvwrapper_initialize() {
13+
test_set_by_user() {
2614
export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs"
2715
mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR"
2816
source "$test_dir/../virtualenvwrapper.sh"
2917
assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]"
3018
}
3119

20+
test_not_set_by_user() {
21+
unset WORKON_HOME
22+
unset VIRTUALENVWRAPPER_LOG_DIR
23+
unset VIRTUALENVWRAPPER_HOOK_DIR
24+
source "$test_dir/../virtualenvwrapper.sh"
25+
assertSame "$WORKON_HOME" "$VIRTUALENVWRAPPER_LOG_DIR"
26+
}
27+
3228
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ then
5656
VIRTUALENVWRAPPER_VIRTUALENV="virtualenv"
5757
fi
5858

59-
# Set the location of the hook scripts
60-
if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ]
61-
then
62-
export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
63-
fi
64-
65-
# Set the location of the hook script logs
66-
if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ]
67-
then
68-
export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
69-
fi
70-
7159
virtualenvwrapper_derive_workon_home() {
7260
typeset workon_home_dir="$WORKON_HOME"
7361

@@ -108,7 +96,7 @@ virtualenvwrapper_derive_workon_home() {
10896
# and maybe other things rely on the dir existing before that happens.
10997
virtualenvwrapper_verify_workon_home () {
11098
RC=0
111-
if [ ! -d "$WORKON_HOME" ]
99+
if [ ! -d "$WORKON_HOME/" ]
112100
then
113101
if [ "$1" != "-q" ]
114102
then
@@ -164,7 +152,21 @@ virtualenvwrapper_run_hook () {
164152
# Set up virtualenvwrapper properly
165153
virtualenvwrapper_initialize () {
166154
export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)"
155+
167156
virtualenvwrapper_verify_workon_home -q || return 1
157+
158+
# Set the location of the hook scripts
159+
if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ]
160+
then
161+
export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
162+
fi
163+
164+
# Set the location of the hook script logs
165+
if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ]
166+
then
167+
export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
168+
fi
169+
168170
virtualenvwrapper_run_hook "initialize"
169171
if [ $? -ne 0 ]
170172
then

0 commit comments

Comments
 (0)