python类Distribution()的实例源码

test_dist.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_obsoletes(self):
        attrs = {"name": "package",
                 "version": "1.0",
                 "obsoletes": ["other", "another (<1.0)"]}
        dist = Distribution(attrs)
        self.assertEqual(dist.metadata.get_obsoletes(),
                         ["other", "another (<1.0)"])
        self.assertEqual(dist.get_obsoletes(),
                         ["other", "another (<1.0)"])
        meta = self.format_metadata(dist)
        self.assertIn("Metadata-Version: 1.1", meta)
        self.assertNotIn("provides:", meta.lower())
        self.assertNotIn("requires:", meta.lower())
        self.assertIn("Obsoletes: other", meta)
        self.assertIn("Obsoletes: another (<1.0)", meta)
test_dist.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_obsoletes_illegal(self):
        self.assertRaises(ValueError, Distribution,
                          {"name": "package",
                           "version": "1.0",
                           "obsoletes": ["my.pkg (splat)"]})
test_dist.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_show_help(self):
        # smoke test, just makes sure some help is displayed
        dist = Distribution()
        sys.argv = []
        dist.help = 1
        dist.script_name = 'setup.py'
        with captured_stdout() as s:
            dist.parse_command_line()

        output = [line for line in s.getvalue().split('\n')
                  if line.strip() != '']
        self.assertTrue(output)
test_dist.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_read_metadata(self):
        attrs = {"name": "package",
                 "version": "1.0",
                 "long_description": "desc",
                 "description": "xxx",
                 "download_url": "http://example.com",
                 "keywords": ['one', 'two'],
                 "requires": ['foo']}

        dist = Distribution(attrs)
        metadata = dist.metadata

        # write it then reloads it
        PKG_INFO = StringIO.StringIO()
        metadata.write_pkg_file(PKG_INFO)
        PKG_INFO.seek(0)
        metadata.read_pkg_file(PKG_INFO)

        self.assertEqual(metadata.name, "package")
        self.assertEqual(metadata.version, "1.0")
        self.assertEqual(metadata.description, "xxx")
        self.assertEqual(metadata.download_url, 'http://example.com')
        self.assertEqual(metadata.keywords, ['one', 'two'])
        self.assertEqual(metadata.platforms, ['UNKNOWN'])
        self.assertEqual(metadata.obsoletes, None)
        self.assertEqual(metadata.requires, ['foo'])
paths.py 文件源码 项目:wheel 作者: pypa 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name': name})
    i = install.install(d)
    i.finalize_options()
    return i
stamp.py 文件源码 项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_command_class(opts, name):
    return opts['cmdclass'].get(name) or Distribution().get_command_class(name)
paths.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
paths.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
test_setup.py 文件源码 项目:devsecops-example-helloworld 作者: boozallen 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def setUp(self):
        super(BuildSphinxTest, self).setUp()

        self.useFixture(fixtures.MonkeyPatch(
            "sphinx.setup_command.BuildDoc.run", lambda self: None))
        from distutils import dist
        self.distr = dist.Distribution()
        self.distr.packages = ("fake_package",)
        self.distr.command_options["build_sphinx"] = {
            "source_dir": ["a", "."]}
        pkg_fixture = fixtures.PythonPackage(
            "fake_package", [("fake_module.py", b""),
                             ("another_fake_module_for_testing.py", b""),
                             ("fake_private_module.py", b"")])
        self.useFixture(pkg_fixture)
        self.useFixture(base.DiveDir(pkg_fixture.base))
        self.distr.command_options["pbr"] = {}
        if hasattr(self, "excludes"):
            self.distr.command_options["pbr"]["autodoc_exclude_modules"] = (
                'setup.cfg',
                "fake_package.fake_private_module\n"
                "fake_package.another_fake_*\n"
                "fake_package.unknown_module")
        if self.has_opt:
            options = self.distr.command_options["pbr"]
            options["autodoc_index_modules"] = ('setup.cfg', self.autodoc)
paths.py 文件源码 项目:ascii-art-py 作者: blinglnav 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
environment.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def use_distribution(self, dist):
        if isinstance(dist, Distribution):
            self._conf = dist.get_option_dict(self._distutils_section)
        else:
            self._conf = dist
pathtool.py 文件源码 项目:aquests 作者: hansroh 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self):
        from distutils.dist import Distribution     
        self.distribution = Distribution()
        self.initialize_options()
paths.py 文件源码 项目:ivaochdoc 作者: ivaoch 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
paths.py 文件源码 项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
paths.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
test_setup.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def setUp(self):
        super(APIAutoDocTest, self).setUp()

        # setup_command requires the Sphinx instance to have some
        # attributes that aren't set normally with the way we use the
        # class (because we replace the constructor). Add default
        # values directly to the class definition.
        import sphinx.application
        sphinx.application.Sphinx.messagelog = []
        sphinx.application.Sphinx.statuscode = 0

        self.useFixture(fixtures.MonkeyPatch(
            "sphinx.application.Sphinx.__init__", lambda *a, **kw: None))
        self.useFixture(fixtures.MonkeyPatch(
            "sphinx.application.Sphinx.build", lambda *a, **kw: None))
        self.useFixture(fixtures.MonkeyPatch(
            "sphinx.application.Sphinx.config", _SphinxConfig))
        self.useFixture(fixtures.MonkeyPatch(
            "sphinx.config.Config.init_values", lambda *a: None))
        self.useFixture(fixtures.MonkeyPatch(
            "sphinx.config.Config.__init__", lambda *a: None))
        from distutils import dist
        self.distr = dist.Distribution()
        self.distr.packages = ("fake_package",)
        self.distr.command_options["build_sphinx"] = {
            "source_dir": ["a", "."]}
        self.sphinx_options = self.distr.command_options["build_sphinx"]
        pkg_fixture = fixtures.PythonPackage(
            "fake_package", [("fake_module.py", b""),
                             ("another_fake_module_for_testing.py", b""),
                             ("fake_private_module.py", b"")])
        self.useFixture(pkg_fixture)
        self.useFixture(base.DiveDir(pkg_fixture.base))
        self.pbr_options = self.distr.command_options.setdefault('pbr', {})
        self.pbr_options["autodoc_index_modules"] = ('setup.cfg', 'True')
paths.py 文件源码 项目:isni-reconcile 作者: cmh2166 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
paths.py 文件源码 项目:AshsSDK 作者: thehappydinoa 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
paths.py 文件源码 项目:habilitacion 作者: GabrielBD 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def get_install_command(name):
    # late binding due to potential monkeypatching
    d = dist.Distribution({'name':name})
    i = install.install(d)
    i.finalize_options()
    return i
locations.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def distutils_scheme(dist_name, user=False, home=None, root=None):
    """
    Return a distutils install scheme
    """
    from distutils.dist import Distribution

    scheme = {}
    d = Distribution({'name': dist_name})
    d.parse_config_files()
    i = d.get_command_obj('install', create=True)
    # NOTE: setting user or home has the side-effect of creating the home dir or
    # user base for installations during finalize_options()
    # ideally, we'd prefer a scheme class that has no side-effects.
    i.user = user or i.user
    i.home = home or i.home
    i.root = root or i.root
    i.finalize_options()
    for key in SCHEME_KEYS:
        scheme[key] = getattr(i, 'install_'+key)

    if running_under_virtualenv():
        scheme['headers'] = os.path.join(sys.prefix,
                                    'include',
                                    'site',
                                    'python' + sys.version[:3],
                                    dist_name)

        if root is not None:
            scheme["headers"] = os.path.join(
                root,
                os.path.abspath(scheme["headers"])[1:],
            )

    return scheme


问题


面经


文章

微信
公众号

扫码关注公众号