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


Python pkg_resources.find_distributions方法代码示例

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


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

示例1: test_odoo_addon1

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_odoo_addon1(self):
        addon1_dir = os.path.join(DATA_DIR, "setup_reusable_addons", "addon1")
        subprocess.check_call([sys.executable, "setup.py", "egg_info"], cwd=addon1_dir)
        egg_info_dir = os.path.join(addon1_dir, "odoo8_addon_addon1.egg-info")
        assert os.path.isdir(egg_info_dir)
        try:
            dist = next(pkg_resources.find_distributions(addon1_dir))
            self.assertEqual(dist.key, "odoo8-addon-addon1")
            self.assertEqual(
                dist.requires(),
                [pkg_resources.Requirement.parse(r) for r in ["odoo>=8.0a,<9.0a"]],
            )
            self.assertTrue(dist.has_metadata("not-zip-safe"))
            self.assertEqual(dist.version, "8.0.1.0.0.99.dev4")
        finally:
            shutil.rmtree(egg_info_dir) 
开发者ID:acsone,项目名称:setuptools-odoo,代码行数:18,代码来源:test_setup_keywords.py

示例2: test_odoo_addon2

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_odoo_addon2(self):
        addon2_dir = os.path.join(DATA_DIR, "setup_reusable_addons", "addon2")
        subprocess.check_call([sys.executable, "setup.py", "egg_info"], cwd=addon2_dir)
        egg_info_dir = os.path.join(addon2_dir, "odoo8_addon_addon2.egg-info")
        assert os.path.isdir(egg_info_dir)
        try:
            dist = next(pkg_resources.find_distributions(addon2_dir))
            self.assertEqual(dist.key, "odoo8-addon-addon2")
            self.assertEqual(
                dist.requires(),
                [
                    pkg_resources.Requirement.parse(r)
                    for r in [
                        "odoo8-addon-addon1",
                        "odoo>=8.0a,<9.0a",
                        "python-dateutil",
                    ]
                ],
            )
            self.assertTrue(dist.has_metadata("not-zip-safe"))
            self.assertEqual(dist.version, "8.0.1.0.1")
        finally:
            shutil.rmtree(egg_info_dir) 
开发者ID:acsone,项目名称:setuptools-odoo,代码行数:25,代码来源:test_setup_keywords.py

示例3: test_odoo_addon4

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_odoo_addon4(self):
        addon4_dir = os.path.join(DATA_DIR, "setup_reusable_addons", "addon4")
        subprocess.check_call([sys.executable, "setup.py", "egg_info"], cwd=addon4_dir)
        egg_info_dir = os.path.join(addon4_dir, "odoo8_addon_addon4.egg-info")
        assert os.path.isdir(egg_info_dir)
        try:
            dist = next(pkg_resources.find_distributions(addon4_dir))
            self.assertEqual(dist.key, "odoo8-addon-addon4")
            self.assertEqual(
                dist.requires(),
                [
                    pkg_resources.Requirement.parse(r)
                    for r in [
                        "astropy>=1.0",
                        "odoo8-addon-addon1>=8.0.3.0.0",
                        "odoo>=8.0a,<9.0a",
                        "python-dateutil",
                    ]
                ],
            )
            self.assertTrue(dist.has_metadata("not-zip-safe"))
            self.assertEqual(dist.version, "8.0.2.0.0")
        finally:
            shutil.rmtree(egg_info_dir) 
开发者ID:acsone,项目名称:setuptools-odoo,代码行数:26,代码来源:test_setup_keywords.py

示例4: parse_directory

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def parse_directory(self):
        if not op.exists(self.directory):
            return {}
        dists = [
            # this magic takes first element or None
            next(iter(
                pkg_resources.find_distributions(op.join(self.directory, item), True)
            ), None)
            for item in os.listdir(self.directory) if '-' in item
        ]
        dists.extend(
            VCSDist(op.join(self.directory, item))
            for item in os.listdir(self.directory) if '+' in item
        )
        dists = filter(None, dists)
        result = defaultdict(list)
        for dist in dists:
            result[dist.key].append(dist)
        return result 
开发者ID:Deepwalker,项目名称:pundler,代码行数:21,代码来源:pundle.py

示例5: check_package_exists

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def check_package_exists(package, lib_dir):
    """Check if a package is installed globally or in lib_dir.

    Returns True when the requirement is met.
    Returns False when the package is not installed or doesn't meet req.
    """
    try:
        req = pkg_resources.Requirement.parse(package)
    except ValueError:
        # This is a zip file
        req = pkg_resources.Requirement.parse(urlparse(package).fragment)

    # Check packages from lib dir
    if lib_dir is not None:
        if any(dist in req for dist in
               pkg_resources.find_distributions(lib_dir)):
            return True

    # Check packages from global + virtual environment
    # pylint: disable=not-an-iterable
    return any(dist in req for dist in pkg_resources.working_set) 
开发者ID:django-leonardo,项目名称:django-leonardo,代码行数:23,代码来源:package.py

示例6: test_distinfo

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_distinfo(self):
        dists = {}
        for d in pkg_resources.find_distributions(self.tmpdir):
            dists[d.project_name] = d

        assert len(dists) == 2, dists

        unversioned = dists['UnversionedDistribution']
        versioned = dists['VersionedDistribution']

        assert versioned.version == '2.718' # from filename
        assert unversioned.version == '0.3' # from METADATA 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:14,代码来源:test_dist_info.py

示例7: test_conditional_dependencies

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_conditional_dependencies(self):
        requires = [pkg_resources.Requirement.parse('splort==4'),
                    pkg_resources.Requirement.parse('quux>=1.1')]

        for d in pkg_resources.find_distributions(self.tmpdir):
            self.assertEqual(d.requires(), requires[:1])
            self.assertEqual(d.requires(extras=('baz',)), requires)
            self.assertEqual(d.extras, ['baz']) 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:10,代码来源:test_dist_info.py

示例8: test_odoo_addon5

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_odoo_addon5(self):
        addon5_dir = os.path.join(DATA_DIR, "setup_reusable_addons", "addon5")
        subprocess.check_call([sys.executable, "setup.py", "egg_info"], cwd=addon5_dir)
        egg_info_dir = os.path.join(addon5_dir, "odoo8_addon_addon5.egg-info")
        assert os.path.isdir(egg_info_dir)
        try:
            dist = next(pkg_resources.find_distributions(addon5_dir))
            self.assertEqual(dist.key, "odoo8-addon-addon5")
        finally:
            shutil.rmtree(egg_info_dir) 
开发者ID:acsone,项目名称:setuptools-odoo,代码行数:12,代码来源:test_setup_keywords.py

示例9: test_custom_project

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_custom_project(self):
        project_dir = os.path.join(DATA_DIR, "setup_custom_project")
        subprocess.check_call([sys.executable, "setup.py", "egg_info"], cwd=project_dir)
        egg_info_dir = os.path.join(project_dir, "test_custom_project.egg-info")
        assert os.path.isdir(egg_info_dir)
        dist = next(pkg_resources.find_distributions(project_dir))
        self.assertEqual(
            dist.requires(),
            [
                pkg_resources.Requirement.parse(r)
                for r in ["pyflakes", "odoo>=8.0a,<9.0a", "python-dateutil"]
            ],
        )
        self.assertFalse(dist.has_metadata("not-zip-safe"))
        shutil.rmtree(egg_info_dir) 
开发者ID:acsone,项目名称:setuptools-odoo,代码行数:17,代码来源:test_setup_keywords.py

示例10: test_non_egg_dir_named_egg

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_non_egg_dir_named_egg(self, target_dir):
        dists = pkg_resources.find_distributions(target_dir)
        assert not list(dists) 
开发者ID:pypa,项目名称:pkg_resources,代码行数:5,代码来源:test_find_distributions.py

示例11: test_standalone_egg_directory

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_standalone_egg_directory(self, project_dir, target_dir):
        # install this distro as an unpacked egg:
        args = [
            sys.executable,
            '-c', 'from setuptools.command.easy_install import main; main()',
            '-mNx',
            '-d', target_dir,
            '--always-unzip',
            project_dir,
        ]
        subprocess.check_call(args)
        dists = pkg_resources.find_distributions(target_dir)
        assert [dist.project_name for dist in dists] == ['my-test-package']
        dists = pkg_resources.find_distributions(target_dir, only=True)
        assert not list(dists) 
开发者ID:pypa,项目名称:pkg_resources,代码行数:17,代码来源:test_find_distributions.py

示例12: test_zipped_egg

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def test_zipped_egg(self, project_dir, target_dir):
        # install this distro as an unpacked egg:
        args = [
            sys.executable,
            '-c', 'from setuptools.command.easy_install import main; main()',
            '-mNx',
            '-d', target_dir,
            '--zip-ok',
            project_dir,
        ]
        subprocess.check_call(args)
        dists = pkg_resources.find_distributions(target_dir)
        assert [dist.project_name for dist in dists] == ['my-test-package']
        dists = pkg_resources.find_distributions(target_dir, only=True)
        assert not list(dists) 
开发者ID:pypa,项目名称:pkg_resources,代码行数:17,代码来源:test_find_distributions.py

示例13: __init__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def __init__(self, directory):
        self.dir = directory
        name = op.split(directory)[-1]
        key, encoded = name.split('+', 1)
        self.key = key.lower()
        self.line = b64decode(encoded).decode('utf-8')
        egg, req, version = parse_vcs_requirement(self.line)
        version = version or '0.0.0'
        self.hashcmp = (pkg_resources_parse_version(version), -1, egg, self.dir)
        self.version = self.line
        self.pkg_resource = next(iter(pkg_resources.find_distributions(self.dir, True)), None)
        self.location = self.pkg_resource.location 
开发者ID:Deepwalker,项目名称:pundler,代码行数:14,代码来源:pundle.py

示例14: create_package_from_setup_py

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def create_package_from_setup_py(self, path_to_setup_py, custom_package_name):
        """
        Creates a package from Setup.py specified in the the given path
        :param path_to_setup_py:
        :return: Package Information: Contains package name, version and path
        """
        if os.path.isfile(path_to_setup_py):
            path_to_setup_py = os.path.abspath(path_to_setup_py)
            setup_py_directory = os.path.dirname(path_to_setup_py)
        elif os.path.isdir(path_to_setup_py):
            setup_py_directory = os.path.abspath(path_to_setup_py)
            path_to_setup_py = setup_py_directory + '/setup.py'
        else:
            raise Exception("Given path/file: " + path_to_setup_py + " doesn't exist")

        if not os.path.exists(path_to_setup_py):
            raise Exception("setup.py doesn't exist in the given path: " + path_to_setup_py)

        sandbox.run_setup(path_to_setup_py, ['sdist'])
        eggs = find_distributions(setup_py_directory)

        version = None
        for egg in eggs:
            if custom_package_name in egg.egg_name():
                version = egg.version

        if not version:
            raise Exception("{package_name} not found".format(package_name=custom_package_name))

        package_info = dict()
        package_info['path'] = setup_py_directory + "/dist/" + custom_package_name + "-" + version + ".tar.gz"
        package_info['version'] = version
        package_info['name'] = custom_package_name
        return package_info 
开发者ID:flipkart-incubator,项目名称:Hunch,代码行数:36,代码来源:hunch_publisher.py

示例15: get_distributions

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import find_distributions [as 别名]
def get_distributions(self):
        # type: () -> Generator[pkg_resources.Distribution, None, None]
        """
        Retrives the distributions installed on the library path of the environment

        :return: A set of distributions found on the library path
        :rtype: iterator
        """

        pkg_resources = self.safe_import("pkg_resources")
        libdirs = self.base_paths["libdirs"].split(os.pathsep)
        dists = (pkg_resources.find_distributions(libdir) for libdir in libdirs)
        for dist in itertools.chain.from_iterable(dists):
            yield dist 
开发者ID:pypa,项目名称:pipenv,代码行数:16,代码来源:environment.py


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