summaryrefslogtreecommitdiff
path: root/src/mailman/config/config.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-05-15 22:22:27 -0400
committerBarry Warsaw2015-05-15 22:23:32 -0400
commite0e97073d97c345ba0fbd0b38925d57c61e01763 (patch)
tree00b9a4ff341f20cba1a7456a3ec0d93d5897be38 /src/mailman/config/config.py
parentda76d9ebae8562a683fc7161af227546fbbc42b8 (diff)
downloadmailman-e0e97073d97c345ba0fbd0b38925d57c61e01763.tar.gz
mailman-e0e97073d97c345ba0fbd0b38925d57c61e01763.tar.zst
mailman-e0e97073d97c345ba0fbd0b38925d57c61e01763.zip
Diffstat (limited to 'src/mailman/config/config.py')
-rw-r--r--src/mailman/config/config.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py
index d23bdda13..e9da7ae4f 100644
--- a/src/mailman/config/config.py
+++ b/src/mailman/config/config.py
@@ -134,8 +134,20 @@ class Configuration:
def _expand_paths(self):
"""Expand all configuration paths."""
- # Set up directories.
- bin_dir = os.path.abspath(os.path.dirname(sys.executable))
+ # First we need to locate the bin directory. This can differ in
+ # several cases, such as, if we're installing into a virtual
+ # environment, /usr/bin, /usr/local/bin, or running the test suite.
+ # We'll try some common locations, looking for a landmark. First
+ # location wins.
+ for origin in (sys.executable, sys.argv[0]):
+ bin_dir = os.path.abspath(os.path.dirname(origin))
+ # Search for 'master' in this directory, since that's the thing we
+ # actually need to be able to run.
+ if os.path.exists(os.path.join(bin_dir, 'master')):
+ break
+ else:
+ print("Could not find the 'master' script", file=sys.stderr)
+ sys.exit(1)
# Now that we've loaded all the configuration files we're going to
# load, set up some useful directories based on the settings in the
# configuration file.