# Set up configuration variables

__all__ = ['custom_viewer', 'qglue', 'test']

import os

import sys

from pkg_resources import get_distribution, DistributionNotFound

try:
    __version__ = get_distribution('glue-core').version
except DistributionNotFound:
    __version__ = 'undefined'

from ._mpl_backend import MatplotlibBackendSetter
sys.meta_path.append(MatplotlibBackendSetter())

from glue.viewers.custom.helper import custom_viewer

# Load user's configuration file
from .config import load_configuration
env = load_configuration()

from .qglue import qglue

from .main import load_plugins  # noqa


def test(no_optional_skip=False):
    from pytest import main
    root = os.path.abspath(os.path.dirname(__file__))
    args = [root, '-x']
    if no_optional_skip:
        args.append('--no-optional-skip')
    return main(args=args)


from glue._settings_helpers import load_settings
load_settings()


# In PyQt 5.5+, PyQt overrides the default exception catching and fatally
# crashes the Qt application without printing out any details about the error.
# Below we revert the exception hook to the original Python one. Note that we
# can't just do sys.excepthook = sys.__excepthook__ otherwise PyQt will detect
# the default excepthook is in place and override it.


def handle_exception(exc_type, exc_value, exc_traceback):
    sys.__excepthook__(exc_type, exc_value, exc_traceback)


sys.excepthook = handle_exception

[((40, 0, 40, 15), 'glue._settings_helpers.load_settings', 'load_settings', ({}, {}), '()', False, 'from glue._settings_helpers import load_settings\n'), ((36, 11, 36, 26), 'pytest.main', 'main', (), '', False, 'from pytest import main\n'), ((51, 4, 51, 58), 'sys.__excepthook__', 'sys.__excepthook__', ({(51, 23, 51, 31): 'exc_type', (51, 33, 51, 42): 'exc_value', (51, 44, 51, 57): 'exc_traceback'}, {}), '(exc_type, exc_value, exc_traceback)', False, 'import sys\n'), ((12, 18, 12, 47), 'pkg_resources.get_distribution', 'get_distribution', ({(12, 35, 12, 46): '"""glue-core"""'}, {}), "('glue-core')", False, 'from pkg_resources import get_distribution, DistributionNotFound\n'), ((32, 27, 32, 52), 'os.path.dirname', 'os.path.dirname', ({(32, 43, 32, 51): '__file__'}, {}), '(__file__)', False, 'import os\n')]