Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

Commit

Permalink
Switch to importlib
Browse files Browse the repository at this point in the history
Seems like even the python 2 version of importlib is enough to handle what we need to do here, rather than relying on the deep magic of __import__.

Testing Done:
https://travis-ci.org/pantsbuild/pants/builds/56241941

Bugs closed: 1342

Reviewed at https://rbcommons.com/s/twitter/r/2003/
  • Loading branch information
gigamonkey authored and jsirois committed Mar 29, 2015
1 parent 0b29805 commit 5563ade
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/python/pants/base/extension_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import importlib
import traceback

from pkg_resources import Requirement, working_set
Expand Down Expand Up @@ -116,16 +117,11 @@ def load_backend(build_configuration, backend_package):
the build configuration."""
backend_module = backend_package + '.register'
try:
module = __import__(backend_module,
{}, # globals
{}, # locals
['build_file_aliases',
'register_goals'])
module = importlib.import_module(backend_module)
except ImportError as e:
traceback.print_exc()
raise BackendConfigurationError('Failed to load the {backend} backend: {error}'
.format(backend=backend_module, error=e))

def invoke_entrypoint(name):
entrypoint = getattr(module, name, lambda: None)
try:
Expand Down

0 comments on commit 5563ade

Please sign in to comment.