当前位置: 首页>>代码示例>>Python>>正文


Python config.read_configuration方法代码示例

本文整理汇总了Python中setuptools.config.read_configuration方法的典型用法代码示例。如果您正苦于以下问题:Python config.read_configuration方法的具体用法?Python config.read_configuration怎么用?Python config.read_configuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在setuptools.config的用法示例。


在下文中一共展示了config.read_configuration方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setuptools_parse_setup_cfg

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def setuptools_parse_setup_cfg(path):
    from setuptools.config import read_configuration

    parsed = read_configuration(path)
    results = parsed.get("metadata", {})
    results.update(parsed.get("options", {}))
    results["install_requires"] = make_base_requirements(
        results.get("install_requires", [])
    )
    extras = {}
    for extras_section, extras_reqs in results.get("extras_require", {}).items():
        new_reqs = tuple(make_base_requirements(extras_reqs))
        if new_reqs:
            extras[extras_section] = new_reqs
    results["extras_require"] = extras
    results["setup_requires"] = make_base_requirements(results.get("setup_requires", []))
    return results 
开发者ID:pypa,项目名称:pipenv,代码行数:19,代码来源:setup_info.py

示例2: test_ignore_errors

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def test_ignore_errors(self, tmpdir):
        _, config = fake_env(
            tmpdir,
            '[metadata]\n'
            'version = attr: none.VERSION\n'
            'keywords = one, two\n'
        )
        with pytest.raises(ImportError):
            read_configuration('%s' % config)

        config_dict = read_configuration(
            '%s' % config, ignore_option_errors=True)

        assert config_dict['metadata']['keywords'] == ['one', 'two']
        assert 'version' not in config_dict['metadata']

        config.remove() 
开发者ID:pypa,项目名称:setuptools,代码行数:19,代码来源:test_config.py

示例3: get_configuration

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def get_configuration(setup_cfg):
    """
    Read the setup.cfg file.

    :param setup_cfg: The path of the setup.cfg file
    :returns: The configuration data
    :rtype: dict
    """
    try:
        # import locally to allow other functions in this module to be usable
        from setuptools.config import read_configuration
    except ImportError as e:
        from pkg_resources import get_distribution
        from pkg_resources import parse_version
        setuptools_version = get_distribution('setuptools').version
        minimum_version = '30.3.0'
        if parse_version(setuptools_version) < parse_version(minimum_version):
            e.msg += ', ' \
                "'setuptools' needs to be at least version " \
                '{minimum_version}, if a newer version is not available ' \
                "from the package manager use 'pip3 install -U setuptools' " \
                'to update to the latest version'.format_map(locals())
        raise
    return read_configuration(str(setup_cfg)) 
开发者ID:colcon,项目名称:colcon-core,代码行数:26,代码来源:python.py

示例4: _extract_version

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def _extract_version(package_name):
    """
    Get package version from installed distribution or configuration file if not
    installed
    """
    try:
        return pkg_resources.get_distribution(package_name).version
    except pkg_resources.DistributionNotFound:
        _conf = read_configuration(os.path.join(PROJECT_DIR, "setup.cfg"))
    return _conf["metadata"]["version"] 
开发者ID:openfun,项目名称:richie,代码行数:12,代码来源:__init__.py

示例5: test_basic

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def test_basic(self, tmpdir):
        _, config = fake_env(
            tmpdir,
            '[metadata]\n'
            'version = 10.1.1\n'
            'keywords = one, two\n'
            '\n'
            '[options]\n'
            'scripts = bin/a.py, bin/b.py\n'
        )
        config_dict = read_configuration('%s' % config)
        assert config_dict['metadata']['version'] == '10.1.1'
        assert config_dict['metadata']['keywords'] == ['one', 'two']
        assert config_dict['options']['scripts'] == ['bin/a.py', 'bin/b.py'] 
开发者ID:pypa,项目名称:setuptools,代码行数:16,代码来源:test_config.py

示例6: test_no_config

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def test_no_config(self, tmpdir):
        with pytest.raises(DistutilsFileError):
            read_configuration('%s' % tmpdir.join('setup.cfg')) 
开发者ID:pypa,项目名称:setuptools,代码行数:5,代码来源:test_config.py

示例7: get_data

# 需要导入模块: from setuptools import config [as 别名]
# 或者: from setuptools.config import read_configuration [as 别名]
def get_data(path):
    """
    Returns data from a package directory.
    'path' should be an absolute path.
    """
    metadata = {}
    # Run the imported setup to get the metadata.
    with FakeContext(path):
        with SetupMonkey() as sm:
            if os.path.isfile("setup.py"):
                try:
                    distro = run_setup("setup.py", stop_after="config")

                    metadata = {"_setuptools": sm.used_setuptools}

                    for k, v in distro.metadata.__dict__.items():
                        if k[0] == "_" or not v:
                            continue
                        if all(not x for x in v):
                            continue
                        metadata[k] = v

                    if sm.used_setuptools:
                        for extras in ["cmdclass", "zip_safe", "test_suite"]:
                            v = getattr(distro, extras, None)
                            if v is not None and v not in ([], {}):
                                metadata[extras] = v
                except Exception as e:
                    # Looks like setup.py is broken.
                    logging.exception(e)
                    metadata = {}

            elif os.path.isfile("setup.cfg"):
                try:
                    from setuptools import config
                    data = config.read_configuration("setup.cfg")
                    metadata = data["metadata"]
                    metadata["_setuptools"] = True
                except Exception as e:
                    logging.exception(e)

            else:
                logging.exception("Neither setup.py nor setup.cfg was found")

    return metadata 
开发者ID:regebro,项目名称:pyroma,代码行数:47,代码来源:projectdata.py


注:本文中的setuptools.config.read_configuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。