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


Python PackageFinder.find_requirement方法代码示例

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


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

示例1: test_finder_only_installs_stable_releases

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_only_installs_stable_releases(data):
    """
    Test PackageFinder only accepts stable versioned releases by default.
    """

    req = InstallRequirement.from_line("bar", None)

    # using a local index (that has pre & dev releases)
    finder = PackageFinder([], [data.index_url("pre")], session=PipSession())
    link = finder.find_requirement(req, False)
    assert link.url.endswith("bar-1.0.tar.gz"), link.url

    # using find-links
    links = ["https://foo/bar-1.0.tar.gz", "https://foo/bar-2.0b1.tar.gz"]
    finder = PackageFinder(links, [], session=PipSession())

    with patch.object(finder, "_get_pages", lambda x, y: []):
        link = finder.find_requirement(req, False)
        assert link.url == "https://foo/bar-1.0.tar.gz"

    links.reverse()
    finder = PackageFinder(links, [], session=PipSession())

    with patch.object(finder, "_get_pages", lambda x, y: []):
        link = finder.find_requirement(req, False)
        assert link.url == "https://foo/bar-1.0.tar.gz"
开发者ID:edmorley,项目名称:pip,代码行数:28,代码来源:test_finder.py

示例2: test_finder_priority_nonegg_over_eggfragments

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_priority_nonegg_over_eggfragments():
    """Test PackageFinder prefers non-egg links over "#egg=" links"""
    req = InstallRequirement.from_line('bar==1.0', None)
    links = ['http://foo/bar.py#egg=bar-1.0', 'http://foo/bar-1.0.tar.gz']

    finder = PackageFinder(links, [], session=PipSession())

    with patch.object(finder, "_get_pages", lambda x, y: []):
        all_versions = finder.find_all_candidates(req.name)
        assert all_versions[0].location.url.endswith('tar.gz')
        assert all_versions[1].location.url.endswith('#egg=bar-1.0')

        link = finder.find_requirement(req, False)

    assert link.url.endswith('tar.gz')

    links.reverse()
    finder = PackageFinder(links, [], session=PipSession())

    with patch.object(finder, "_get_pages", lambda x, y: []):
        all_versions = finder.find_all_candidates(req.name)
        assert all_versions[0].location.url.endswith('tar.gz')
        assert all_versions[1].location.url.endswith('#egg=bar-1.0')
        link = finder.find_requirement(req, False)

    assert link.url.endswith('tar.gz')
开发者ID:edmorley,项目名称:pip,代码行数:28,代码来源:test_finder.py

示例3: test_tilde

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_tilde():
    """Finder can accept a path with ~ in it and will normalize it."""
    session = PipSession()
    with patch('pip._internal.index.os.path.exists', return_value=True):
        finder = PackageFinder(['~/python-pkgs'], [], session=session)
    req = InstallRequirement.from_line("gmpy")
    with pytest.raises(DistributionNotFound):
        finder.find_requirement(req, False)
开发者ID:edmorley,项目名称:pip,代码行数:10,代码来源:test_finder.py

示例4: test_finder_detects_latest_already_satisfied_find_links

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_detects_latest_already_satisfied_find_links(data):
    """Test PackageFinder detects latest already satisfied using find-links"""
    req = InstallRequirement.from_line('simple', None)
    # the latest simple in local pkgs is 3.0
    latest_version = "3.0"
    satisfied_by = Mock(
        location="/path",
        parsed_version=parse_version(latest_version),
        version=latest_version
    )
    req.satisfied_by = satisfied_by
    finder = PackageFinder([data.find_links], [], session=PipSession())

    with pytest.raises(BestVersionAlreadyInstalled):
        finder.find_requirement(req, True)
开发者ID:edmorley,项目名称:pip,代码行数:17,代码来源:test_finder.py

示例5: test_no_mpkg

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_no_mpkg(data):
    """Finder skips zipfiles with "macosx10" in the name."""
    finder = PackageFinder([data.find_links], [], session=PipSession())
    req = InstallRequirement.from_line("pkgwithmpkg")
    found = finder.find_requirement(req, False)

    assert found.url.endswith("pkgwithmpkg-1.0.tar.gz"), found
开发者ID:edmorley,项目名称:pip,代码行数:9,代码来源:test_finder.py

示例6: test_no_partial_name_match

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_no_partial_name_match(data):
    """Finder requires the full project name to match, not just beginning."""
    finder = PackageFinder([data.find_links], [], session=PipSession())
    req = InstallRequirement.from_line("gmpy")
    found = finder.find_requirement(req, False)

    assert found.url.endswith("gmpy-1.15.tar.gz"), found
开发者ID:edmorley,项目名称:pip,代码行数:9,代码来源:test_finder.py

示例7: test_skip_invalid_wheel_link

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
    def test_skip_invalid_wheel_link(self, caplog, data):
        """
        Test if PackageFinder skips invalid wheel filenames
        """
        req = InstallRequirement.from_line("invalid")
        # data.find_links contains "invalid.whl", which is an invalid wheel
        finder = PackageFinder(
            [data.find_links],
            [],
            session=PipSession(),
        )
        with pytest.raises(DistributionNotFound):
            finder.find_requirement(req, True)

        assert (
            "invalid.whl; invalid wheel filename"
            in caplog.text
        )
开发者ID:edmorley,项目名称:pip,代码行数:20,代码来源:test_finder.py

示例8: test_finder_detects_latest_already_satisfied_pypi_links

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_detects_latest_already_satisfied_pypi_links():
    """Test PackageFinder detects latest already satisfied using pypi links"""
    req = InstallRequirement.from_line('initools', None)
    # the latest initools on pypi is 0.3.1
    latest_version = "0.3.1"
    satisfied_by = Mock(
        location="/path",
        parsed_version=parse_version(latest_version),
        version=latest_version,
    )
    req.satisfied_by = satisfied_by
    finder = PackageFinder(
        [],
        ["http://pypi.python.org/simple"],
        session=PipSession(),
    )

    with pytest.raises(BestVersionAlreadyInstalled):
        finder.find_requirement(req, True)
开发者ID:edmorley,项目名称:pip,代码行数:21,代码来源:test_finder.py

示例9: test_finder_installs_pre_releases_with_version_spec

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_installs_pre_releases_with_version_spec():
    """
    Test PackageFinder only accepts stable versioned releases by default.
    """
    req = InstallRequirement.from_line("bar>=0.0.dev0", None)
    links = ["https://foo/bar-1.0.tar.gz", "https://foo/bar-2.0b1.tar.gz"]

    finder = PackageFinder(links, [], session=PipSession())

    with patch.object(finder, "_get_pages", lambda x, y: []):
        link = finder.find_requirement(req, False)
        assert link.url == "https://foo/bar-2.0b1.tar.gz"

    links.reverse()
    finder = PackageFinder(links, [], session=PipSession())

    with patch.object(finder, "_get_pages", lambda x, y: []):
        link = finder.find_requirement(req, False)
        assert link.url == "https://foo/bar-2.0b1.tar.gz"
开发者ID:edmorley,项目名称:pip,代码行数:21,代码来源:test_finder.py

示例10: test_not_find_wheel_not_supported

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
    def test_not_find_wheel_not_supported(self, data, monkeypatch):
        """
        Test not finding an unsupported wheel.
        """
        monkeypatch.setattr(
            pip._internal.pep425tags,
            "get_supported",
            lambda **kw: [("py1", "none", "any")],
        )

        req = InstallRequirement.from_line("simple.dist")
        finder = PackageFinder(
            [data.find_links],
            [],
            session=PipSession(),
        )
        finder.valid_tags = pip._internal.pep425tags.get_supported()

        with pytest.raises(DistributionNotFound):
            finder.find_requirement(req, True)
开发者ID:edmorley,项目名称:pip,代码行数:22,代码来源:test_finder.py

示例11: test_duplicates_sort_ok

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_duplicates_sort_ok(data):
    """Finder successfully finds one of a set of duplicates in different
    locations"""
    finder = PackageFinder(
        [data.find_links, data.find_links2],
        [],
        session=PipSession(),
    )
    req = InstallRequirement.from_line("duplicate")
    found = finder.find_requirement(req, False)

    assert found.url.endswith("duplicate-1.0.tar.gz"), found
开发者ID:edmorley,项目名称:pip,代码行数:14,代码来源:test_finder.py

示例12: test_existing_over_wheel_priority

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
    def test_existing_over_wheel_priority(self, data):
        """
        Test existing install has priority over wheels.
        `test_link_sorting` also covers this at a lower level
        """
        req = InstallRequirement.from_line('priority', None)
        latest_version = "1.0"
        satisfied_by = Mock(
            location="/path",
            parsed_version=parse_version(latest_version),
            version=latest_version,
        )
        req.satisfied_by = satisfied_by
        finder = PackageFinder(
            [data.find_links],
            [],
            session=PipSession(),
        )

        with pytest.raises(BestVersionAlreadyInstalled):
            finder.find_requirement(req, True)
开发者ID:edmorley,项目名称:pip,代码行数:23,代码来源:test_finder.py

示例13: test_wheel_over_sdist_priority

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
 def test_wheel_over_sdist_priority(self, data):
     """
     Test wheels have priority over sdists.
     `test_link_sorting` also covers this at lower level
     """
     req = InstallRequirement.from_line("priority")
     finder = PackageFinder(
         [data.find_links],
         [],
         session=PipSession(),
     )
     found = finder.find_requirement(req, True)
     assert found.url.endswith("priority-1.0-py2.py3-none-any.whl"), found
开发者ID:edmorley,项目名称:pip,代码行数:15,代码来源:test_finder.py

示例14: test_finder_installs_pre_releases

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_installs_pre_releases(data):
    """
    Test PackageFinder finds pre-releases if asked to.
    """

    req = InstallRequirement.from_line("bar", None)

    # using a local index (that has pre & dev releases)
    finder = PackageFinder(
        [], [data.index_url("pre")],
        allow_all_prereleases=True,
        session=PipSession(),
    )
    link = finder.find_requirement(req, False)
    assert link.url.endswith("bar-2.0b1.tar.gz"), link.url

    # using find-links
    links = ["https://foo/bar-1.0.tar.gz", "https://foo/bar-2.0b1.tar.gz"]
    finder = PackageFinder(
        links, [],
        allow_all_prereleases=True,
        session=PipSession(),
    )

    with patch.object(finder, "_get_pages", lambda x, y: []):
        link = finder.find_requirement(req, False)
        assert link.url == "https://foo/bar-2.0b1.tar.gz"

    links.reverse()
    finder = PackageFinder(
        links, [],
        allow_all_prereleases=True,
        session=PipSession(),
    )

    with patch.object(finder, "_get_pages", lambda x, y: []):
        link = finder.find_requirement(req, False)
        assert link.url == "https://foo/bar-2.0b1.tar.gz"
开发者ID:edmorley,项目名称:pip,代码行数:40,代码来源:test_finder.py

示例15: test_finder_installs_dev_releases

# 需要导入模块: from pip._internal.index import PackageFinder [as 别名]
# 或者: from pip._internal.index.PackageFinder import find_requirement [as 别名]
def test_finder_installs_dev_releases(data):
    """
    Test PackageFinder finds dev releases if asked to.
    """

    req = InstallRequirement.from_line("bar", None)

    # using a local index (that has dev releases)
    finder = PackageFinder(
        [], [data.index_url("dev")],
        allow_all_prereleases=True,
        session=PipSession(),
    )
    link = finder.find_requirement(req, False)
    assert link.url.endswith("bar-2.0.dev1.tar.gz"), link.url
开发者ID:edmorley,项目名称:pip,代码行数:17,代码来源:test_finder.py


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