Make lib_dir optional and configurable.

This commit is contained in:
Devan Goodwin 2010-05-23 10:47:50 -03:00
parent 0149172278
commit 2cd407dfe9

View file

@ -43,12 +43,6 @@ builder = tito.builder.NoTgzBuilder
tagger = tito.tagger.ReleaseTagger tagger = tito.tagger.ReleaseTagger
""" """
lib_dir = os.path.join(find_git_root(), "rel-eng", "lib")
if os.path.exists(lib_dir):
sys.path.append(lib_dir)
debug("Added lib dir to PYTHONPATH: %s." % lib_dir)
def read_user_config(): def read_user_config():
config = {} config = {}
file_loc = os.path.expanduser("~/.spacewalk-build-rc") file_loc = os.path.expanduser("~/.spacewalk-build-rc")
@ -163,6 +157,23 @@ class BaseCliModule(object):
if self.options.debug: if self.options.debug:
os.environ['DEBUG'] = "true" os.environ['DEBUG'] = "true"
# Check if global config defines a custom lib dir:
if self.global_config.has_option(GLOBALCONFIG_SECTION,
"lib_dir"):
lib_dir = self.global_config.get(GLOBALCONFIG_SECTION,
"lib_dir")
if lib_dir[0] != '/':
# Looks like a relative path, assume from the git root:
lib_dir = os.path.join(find_git_root(), lib_dir)
if os.path.exists(lib_dir):
sys.path.append(lib_dir)
debug("Added lib dir to PYTHONPATH: %s" % lib_dir)
else:
print("WARNING: lib_dir specified but does not exist: %s" %
lib_dir)
def _read_global_config(self): def _read_global_config(self):
""" """
Read global build.py configuration from the rel-eng dir of the git Read global build.py configuration from the rel-eng dir of the git