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


Python InstallRequirement.from_line方法代码示例

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


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

示例1: test_unexisting_path

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
 def test_unexisting_path(self):
     with pytest.raises(InstallationError) as e:
         InstallRequirement.from_line(
             os.path.join('this', 'path', 'does', 'not', 'exist'))
     err_msg = e.value.args[0]
     assert "Invalid requirement" in err_msg
     assert "It looks like a path." in err_msg
开发者ID:oz123,项目名称:pip,代码行数:9,代码来源:test_req.py

示例2: test_exclusive_environment_markers

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
def test_exclusive_environment_markers():
    """Make sure RequirementSet accepts several excluding env markers"""
    eq26 = InstallRequirement.from_line(
        "Django>=1.6.10,<1.7 ; python_version == '2.6'")
    ne26 = InstallRequirement.from_line(
        "Django>=1.6.10,<1.8 ; python_version != '2.6'")

    req_set = RequirementSet('', '', '')
    req_set.add_requirement(eq26)
    req_set.add_requirement(ne26)
    assert req_set.has_requirement('Django')
开发者ID:oz123,项目名称:pip,代码行数:13,代码来源:test_req.py

示例3: test_requirement_file

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
 def test_requirement_file(self):
     req_file_path = os.path.join(self.tempdir, 'test.txt')
     with open(req_file_path, 'w') as req_file:
         req_file.write('pip\nsetuptools')
     with pytest.raises(InstallationError) as e:
         InstallRequirement.from_line(req_file_path)
     err_msg = e.value.args[0]
     assert "Invalid requirement" in err_msg
     assert "It looks like a path. It does exist." in err_msg
     assert "appears to be a requirements file." in err_msg
     assert "If that is the case, use the '-r' flag to install" in err_msg
开发者ID:oz123,项目名称:pip,代码行数:13,代码来源:test_req.py

示例4: test_markers_url

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
    def test_markers_url(self):
        # test "URL; markers" syntax
        url = 'http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz'
        line = '%s; python_version >= "3"' % url
        req = InstallRequirement.from_line(line)
        assert req.link.url == url, req.url
        assert str(req.markers) == 'python_version >= "3"'

        # without space, markers are part of the URL
        url = 'http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz'
        line = '%s;python_version >= "3"' % url
        req = InstallRequirement.from_line(line)
        assert req.link.url == line, req.url
        assert req.markers is None
开发者ID:oz123,项目名称:pip,代码行数:16,代码来源:test_req.py

示例5: test_no_partial_name_match

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [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

示例6: test_no_mpkg

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [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

示例7: test_finder_only_installs_stable_releases

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [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

示例8: test_extras_for_line_path_requirement

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
 def test_extras_for_line_path_requirement(self):
     line = 'SomeProject[ex1,ex2]'
     filename = 'filename'
     comes_from = '-r %s (line %s)' % (filename, 1)
     req = InstallRequirement.from_line(line, comes_from=comes_from)
     assert len(req.extras) == 2
     assert req.extras == {'ex1', 'ex2'}
开发者ID:edmorley,项目名称:pip,代码行数:9,代码来源:test_req.py

示例9: test_extras_for_line_url_requirement

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
 def test_extras_for_line_url_requirement(self):
     line = 'git+https://url#egg=SomeProject[ex1,ex2]'
     filename = 'filename'
     comes_from = '-r %s (line %s)' % (filename, 1)
     req = InstallRequirement.from_line(line, comes_from=comes_from)
     assert len(req.extras) == 2
     assert req.extras == set(['ex1', 'ex2'])
开发者ID:oz123,项目名称:pip,代码行数:9,代码来源:test_req.py

示例10: test_get_dist

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
 def test_get_dist(self):
     req = InstallRequirement.from_line('foo')
     req.egg_info_path = Mock(return_value='/path/to/foo.egg-info')
     dist = req.get_dist()
     assert isinstance(dist, pkg_resources.Distribution)
     assert dist.project_name == 'foo'
     assert dist.location == '/path/to'
开发者ID:oz123,项目名称:pip,代码行数:9,代码来源:test_req.py

示例11: test_finder_priority_nonegg_over_eggfragments

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [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

示例12: run

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
    def run(self, options, args):
        with self._build_session(options) as session:
            reqs_to_uninstall = {}
            for name in args:
                req = InstallRequirement.from_line(
                    name, isolated=options.isolated_mode,
                )
                if req.name:
                    reqs_to_uninstall[canonicalize_name(req.name)] = req
            for filename in options.requirements:
                for req in parse_requirements(
                        filename,
                        options=options,
                        session=session):
                    if req.name:
                        reqs_to_uninstall[canonicalize_name(req.name)] = req
            if not reqs_to_uninstall:
                raise InstallationError(
                    'You must give at least one requirement to %(name)s (see '
                    '"pip help %(name)s")' % dict(name=self.name)
                )

            protect_pip_from_modification_on_windows(
                modifying_pip="pip" in reqs_to_uninstall
            )

            for req in reqs_to_uninstall.values():
                uninstall_pathset = req.uninstall(
                    auto_confirm=options.yes, verbose=self.verbosity > 0,
                )
                if uninstall_pathset:
                    uninstall_pathset.commit()
开发者ID:547358880,项目名称:flask-tutorial,代码行数:34,代码来源:uninstall.py

示例13: test_get_dist_trailing_slash

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
 def test_get_dist_trailing_slash(self):
     # Tests issue fixed by https://github.com/pypa/pip/pull/2530
     req = InstallRequirement.from_line('foo')
     req.egg_info_path = Mock(return_value='/path/to/foo.egg-info/')
     dist = req.get_dist()
     assert isinstance(dist, pkg_resources.Distribution)
     assert dist.project_name == 'foo'
     assert dist.location == '/path/to'
开发者ID:oz123,项目名称:pip,代码行数:10,代码来源:test_req.py

示例14: test_get_index_urls_locations

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [as 别名]
def test_get_index_urls_locations():
    """Check that the canonical name is on all indexes"""
    finder = PackageFinder(
        [], ['file://index1/', 'file://index2'], session=PipSession())
    locations = finder._get_index_urls_locations(
        InstallRequirement.from_line('Complex_Name').name)
    assert locations == ['file://index1/complex-name/',
                         'file://index2/complex-name/']
开发者ID:edmorley,项目名称:pip,代码行数:10,代码来源:test_finder.py

示例15: test_tilde

# 需要导入模块: from pip._internal.req import InstallRequirement [as 别名]
# 或者: from pip._internal.req.InstallRequirement import from_line [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


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