Bug 1415618: Use path relative to mozharness config modules to find configs. r=jlund
authorTom Prince <mozilla@hocat.ca>
Sat, 11 Nov 2017 13:50:21 -0700
changeset 392109 1258a1b9888f370c761bf1307d0e6f174bbdf02c
parent 392108 501306f6fc2251fa251f1071b2eee31ddb44ba52
child 392110 796e3f06ba999535279c8afe889be3d91c8edbc2
push id32910
push userrgurzau@mozilla.com
push dateThu, 16 Nov 2017 10:02:59 +0000
treeherdermozilla-central@9941e68b5a53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlund
bugs1415618
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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