Make the scripts in bin/ detect if they're being run from a bzr checkout

or an extracted release tarball or whatever and adjust PYTHONPATH
accordingly.
This commit is contained in:
Soren Hansen
2010-09-08 10:45:39 +02:00
parent 9952e1cd69
commit cd42029321
10 changed files with 99 additions and 4 deletions

View File

@@ -21,6 +21,17 @@
Twisted daemon for nova objectstore. Supports S3 API.
"""
import os
import sys
# If ../nova/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
from nova import flags
from nova import utils
from nova import twistd