Bug 1415618: Use path relative to mozharness config modules to find configs. r=jlund
☠☠ backed out by b89090531f6a ☠ ☠
authorTom Prince <mozilla@hocat.ca>
Sat, 11 Nov 2017 13:50:21 -0700
changeset 392091 5ecdc55db739801216435854ce412694a8e0dca7
parent 392090 be317382298705c63d0be2f4686eaa7ca513ea6c
child 392092 780f67a36d6d91d4ee35070dc7f8d8c598106929
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