Bug 1415618: Use path relative to mozharness config modules to find configs. r=jlund draft
authorTom Prince <mozilla@hocat.ca>
Sat, 11 Nov 2017 13:50:21 -0700
changeset 698842 77fb6c02d5e3f4e7011f0bef5ee22708145d3702
parent 698841 08b3ecd32f4ba272a15ccb79faea621a2208f32b
child 698843 e80f0f20213e76ee68e62757eab8c788b7d398c6
push id89369
push userbmo:mozilla@hocat.ca
push dateThu, 16 Nov 2017 04:26:10 +0000
reviewersjlund
bugs1415618
milestone59.0a1
Bug 1415618: Use path relative to mozharness config modules to find configs. r=jlund MozReview-Commit-ID: 6D6QEz9ulYX
testing/mozharness/mozharness/base/config.py
testing/mozharness/mozharness/mozilla/building/buildbase.py
--- a/testing/mozharness/mozharness/base/config.py
+++ b/testing/mozharness/mozharness/base/config.py
@@ -130,28 +130,29 @@ class ReadOnlyDict(dict):
         memo[id(self)] = result
         for k, v in self.__dict__.items():
             setattr(result, k, deepcopy(v, memo))
         result._lock = False
         for k, v in self.items():
             result[k] = deepcopy(v, memo)
         return result
 
+DEFAULT_CONFIG_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "configs")
+
 # parse_config_file {{{1
 def parse_config_file(file_name, quiet=False, search_path=None,
                       config_dict_name="config"):
     """Read a config file and return a dictionary.
     """
     file_path = None
     if os.path.exists(file_name):
         file_path = file_name
     else:
         if not search_path:
-            search_path = ['.', os.path.join(sys.path[0], '..', 'configs'),
-                           os.path.join(sys.path[0], '..', '..', 'configs')]
+            search_path = ['.', DEFAULT_CONFIG_PATH]
         for path in search_path:
             if os.path.exists(os.path.join(path, file_name)):
                 file_path = os.path.join(path, file_name)
                 break
         else:
             raise IOError("Can't find %s in %s!" % (file_name, search_path))
     if file_name.endswith('.py'):
         global_dict = {}
--- a/testing/mozharness/mozharness/mozilla/building/buildbase.py
+++ b/testing/mozharness/mozharness/mozilla/building/buildbase.py
@@ -21,17 +21,17 @@ import copy
 import glob
 import shlex
 from itertools import chain
 
 # import the power of mozharness ;)
 import sys
 from datetime import datetime
 import re
-from mozharness.base.config import BaseConfig, parse_config_file
+from mozharness.base.config import BaseConfig, parse_config_file, DEFAULT_CONFIG_PATH
 from mozharness.base.log import ERROR, OutputParser, FATAL
 from mozharness.base.script import PostScriptRun
 from mozharness.base.vcs.vcsbase import MercurialScript
 from mozharness.mozilla.buildbot import (
     BuildbotMixin,
     EXIT_STATUS_DICT,
     TBPL_STATUS_DICT,
     TBPL_EXCEPTION,
@@ -395,18 +395,17 @@ class BuildingConfig(BaseConfig):
 
 
 # noinspection PyUnusedLocal
 class BuildOptionParser(object):
     # TODO add nosetests for this class
     platform = None
     bits = None
     config_file_search_path = [
-        '.', os.path.join(sys.path[0], '..', 'configs'),
-        os.path.join(sys.path[0], '..', '..', 'configs')
+        DEFAULT_CONFIG_PATH,
     ]
 
     # add to this list and you can automagically do things like
     # --custom-build-variant-cfg asan
     # and the script will pull up the appropriate path for the config
     # against the current platform and bits.
     # *It will warn and fail if there is not a config for the current
     # platform/bits