Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: recipe_engine/loader.py

Issue 1592973003: Allow base path overrides when running a recipe. (Closed) Base URL: git@github.com:luci/recipes-py.git@isolate
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | recipe_modules/path/api.py » ('j') | recipe_modules/path/config.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013-2015 The Chromium Authors. All rights reserved. 1 # Copyright 2013-2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import contextlib 6 import contextlib
7 import imp 7 import imp
8 import inspect 8 import inspect
9 import os 9 import os
10 import sys 10 import sys
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 def _load_recipe_module_module(path, universe_view): 344 def _load_recipe_module_module(path, universe_view):
345 modname = os.path.splitext(os.path.basename(path))[0] 345 modname = os.path.splitext(os.path.basename(path))[0]
346 fullname = '%s.%s' % (RECIPE_MODULE_PREFIX, modname) 346 fullname = '%s.%s' % (RECIPE_MODULE_PREFIX, modname)
347 mod = _find_and_load_module(fullname, modname, path) 347 mod = _find_and_load_module(fullname, modname, path)
348 348
349 # This actually loads the dependencies. 349 # This actually loads the dependencies.
350 mod.LOADED_DEPS = universe_view.deps_from_spec(getattr(mod, 'DEPS', [])) 350 mod.LOADED_DEPS = universe_view.deps_from_spec(getattr(mod, 'DEPS', []))
351 351
352 # Prevent any modules that mess with sys.path from leaking. 352 # Prevent any modules that mess with sys.path from leaking.
353 with _preserve_path(): 353 with _preserve_path():
354 # TODO(luqui): Remove this hack once configs are cleaned.
355 sys.modules['%s.DEPS' % fullname] = mod.LOADED_DEPS 354 sys.modules['%s.DEPS' % fullname] = mod.LOADED_DEPS
356 _recursive_import(path, RECIPE_MODULE_PREFIX) 355 _recursive_import(path, RECIPE_MODULE_PREFIX)
357 _patchup_module(modname, mod, universe_view) 356 _patchup_module(modname, mod, universe_view)
358 357
359 return mod 358 return mod
360 359
361 360
362 def _recursive_import(path, prefix): 361 def _recursive_import(path, prefix):
363 modname = os.path.splitext(os.path.basename(path))[0] 362 modname = os.path.splitext(os.path.basename(path))[0]
364 fullname = '%s.%s' % (prefix, modname) 363 fullname = '%s.%s' % (prefix, modname)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod) 571 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod)
573 for k,v in deps.iteritems(): 572 for k,v in deps.iteritems():
574 setattr(modapi.m, k, v) 573 setattr(modapi.m, k, v)
575 return modapi 574 return modapi
576 575
577 mapper = DependencyMapper(instantiator) 576 mapper = DependencyMapper(instantiator)
578 api = RecipeTestApi(module=None) 577 api = RecipeTestApi(module=None)
579 for k,v in toplevel_deps.iteritems(): 578 for k,v in toplevel_deps.iteritems():
580 setattr(api, k, mapper.instantiate(v)) 579 setattr(api, k, mapper.instantiate(v))
581 return api 580 return api
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/path/api.py » ('j') | recipe_modules/path/config.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698