diff --git a/dpaste/settings/base.py b/dpaste/settings/base.py index 0dcabf7..cc89dd9 100644 --- a/dpaste/settings/base.py +++ b/dpaste/settings/base.py @@ -13,12 +13,18 @@ PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split( os.path.dirname(os.path.realpath(dpaste.__file__)) ) -# Set the variable root to $VIRTUALENV/var. PYTHON_BIN = os.path.dirname(sys.executable) - -VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var') -if not os.path.exists(VAR_ROOT): - os.mkdir(VAR_ROOT) +if os.path.exists(os.path.join(PYTHON_BIN, 'activate_this.py')): + # Assume that the presence of 'activate_this.py' in the python bin/ + # directory means that we're running in a virtual environment. Set the + # variable root to $VIRTUALENV/var. + VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var') + if not os.path.exists(VAR_ROOT): + os.mkdir(VAR_ROOT) +else: + # Set the variable root to the local configuration location (which is + # ignored by the repository). + VAR_ROOT = os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'conf', 'local') #============================================================================== # Generic Django project settings