import types
import codecs


def get_config_from_py_file(config_path):
    """
    Load a configuration from a .py file.

    :param config_path: Path to configuration file.
    :type config_path: str
    :return: Configuration parameters as a dictionary.
    :rtype: dict
    """
    config = types.ModuleType('config')
    config.__file__ = config_path

    try:
        with codecs.open(config_path, "rb", "utf-8") as config_file:
            exec(compile(config_file.read(), config_path, 'exec'),
                 config.__dict__)
    except IOError:
        pass

    return {
        key: getattr(config, key) for key in dir(config) if key.isupper()
    }