From bea1aa811ad7f3f290f3fa44f0ab6481233eab27 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Tue, 12 Dec 2017 22:27:17 +0100 Subject: [PATCH] Reset to 'standard' folders --- dpaste/settings/base.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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