Exemplo n.º 1
0
    def _get_dependencies(self, ireq):
        if ireq.editable:
            return self.editables[str(ireq.link)]

        name, version, extras = as_tuple(ireq)
        # Store non-extra dependencies under the empty string
        extras += ("",)
        dependencies = [dep for extra in extras for dep in self.index[name][version][extra]]
        return [InstallRequirement.from_line(dep, constraint=ireq.constraint) for dep in dependencies]
Exemplo n.º 2
0
 def find_best_match(self, ireq, prereleases=None):
     key = key_from_req(ireq.req)
     existing_pin = self.existing_pins.get(key)
     if existing_pin and ireq_satisfied_by_existing_pin(ireq, existing_pin):
         project, version, _ = as_tuple(existing_pin)
         return make_install_requirement(project,
                                         version,
                                         ireq.extras,
                                         constraint=ireq.constraint)
     else:
         return self.repository.find_best_match(ireq, prereleases)
Exemplo n.º 3
0
def test_as_tuple(from_line):
    ireq = from_line('foo==1.1')
    name, version, extras = as_tuple(ireq)
    assert name == 'foo'
    assert version == '1.1'
    assert extras == ()

    ireq = from_line('foo[extra1,extra2]==1.1')
    name, version, extras = as_tuple(ireq)
    assert name == 'foo'
    assert version == '1.1'
    assert extras == ("extra1", "extra2")

    # Non-pinned versions return None as version
    non_pinneds = [
        'foo==1.*',
        'foo~=1.1,<1.5,>1.2',
        'foo',
    ]
    for spec in non_pinneds:
        ireq = from_line(spec)
        assert as_tuple(ireq)[1] is None
Exemplo n.º 4
0
def test_as_tuple(from_line):
    ireq = from_line('foo==1.1')
    name, version, extras = as_tuple(ireq)
    assert name == 'foo'
    assert version == '1.1'
    assert extras == ()

    ireq = from_line('foo[extra1,extra2]==1.1')
    name, version, extras = as_tuple(ireq)
    assert name == 'foo'
    assert version == '1.1'
    assert extras == ("extra1", "extra2")

    # Non-pinned versions aren't accepted
    should_be_rejected = [
        'foo==1.*',
        'foo~=1.1,<1.5,>1.2',
        'foo',
    ]
    for spec in should_be_rejected:
        ireq = from_line(spec)
        with raises(TypeError):
            as_tuple(ireq)