Example #1
0
def test_wheel_precedence():
    linux_whl = WheelPackage(
        'protobuf-3.6.1-cp27-cp27mu-manylinux1_x86_64.whl')
    none_whl = WheelPackage('protobuf-3.6.1-py2.py3-none-any.whl')

    assert Sorter().sort([linux_whl, none_whl]) == [linux_whl, none_whl]
    assert Sorter().sort([none_whl, linux_whl]) == [linux_whl, none_whl]
Example #2
0
def test_different_wheel_packages_should_be_equal():
    pypi_package = WheelPackage(
        'https://pypi.python.org/packages/9b/31/'
        'e9925a2b9a06f97c3450bac6107928d3533bfe64ca5615442504104321e8/'
        'requests-2.12.1-py2.py3-none-any.whl')
    local_package = WheelPackage(
        'https://internalpypi.mycompany.org/packages/9b/31/'
        'e9925a2b9a06f97c3450bac6107928d3533bfe64ca5615442504104321e8/'
        'requests-2.12.1-py2.py3-none-any.whl')
    assert pypi_package == local_package
Example #3
0
def test_wheel_package():
    wp = WheelPackage(
        'file:///home/user/.pex/build/requests-2.12.1-py2.py3-none-any.whl')
    assert wp.name == "requests"
    assert wp.raw_version == "2.12.1"
    assert wp._py_tag == "py2.py3"
    assert wp._abi_tag == "none"
    assert wp._arch_tag == "any"
Example #4
0
def test_iter_ordering():
    pi = PythonInterpreter.get()
    tgz = SourcePackage('psutil-0.6.1.tar.gz')
    egg = EggPackage('psutil-0.6.1-py%s-%s.egg' %
                     (pi.python, get_build_platform()))
    whl = WheelPackage(
        'psutil-0.6.1-cp%s-none-%s.whl' %
        (pi.python.replace('.', ''), get_build_platform().replace(
            '-', '_').replace('.', '_').lower()))
    req = Requirement.parse('psutil')

    assert list(FakeIterator([tgz, egg, whl]).iter(req)) == [whl, egg, tgz]
    assert list(FakeIterator([egg, tgz, whl]).iter(req)) == [whl, egg, tgz]
Example #5
0
def test_sorter_sort():
  pi = PythonInterpreter.get()
  tgz = SourcePackage('psutil-0.6.1.tar.gz')
  egg = EggPackage('psutil-0.6.1-py%s-%s.egg' % (pi.python, get_build_platform()))
  whl = WheelPackage('psutil-0.6.1-cp%s-none-%s.whl' % (
      pi.python.replace('.', ''),
      get_build_platform().replace('-', '_').replace('.', '_').lower()))

  assert Sorter().sort([tgz, egg, whl]) == [whl, egg, tgz]
  assert Sorter().sort([egg, tgz, whl]) == [whl, egg, tgz]

  # test unknown type
  sorter = Sorter(precedence=(EggPackage, WheelPackage))
  assert sorter.sort([egg, tgz, whl], filter=False) == [egg, whl, tgz]
  assert sorter.sort([egg, tgz, whl], filter=True) == [egg, whl]
Example #6
0
def test_package_precedence():
  source = SourcePackage('psutil-0.6.1.tar.gz')
  egg = EggPackage('psutil-0.6.1-py2.6.egg')
  whl = WheelPackage('psutil-0.6.1-cp26-none-macosx_10_4_x86_64.whl')

  # default precedence
  assert Sorter.package_precedence(whl) > Sorter.package_precedence(egg)
  assert Sorter.package_precedence(egg) > Sorter.package_precedence(source)
  assert Sorter.package_precedence(whl) > Sorter.package_precedence(source)

  # overridden precedence
  PRECEDENCE = (EggPackage, WheelPackage)
  assert Sorter.package_precedence(source, PRECEDENCE) == (
      source.version, -1, 0, True, source.url)  # unknown rank
  assert Sorter.package_precedence(whl, PRECEDENCE) > Sorter.package_precedence(
      source, PRECEDENCE)
  assert Sorter.package_precedence(egg, PRECEDENCE) > Sorter.package_precedence(
      whl, PRECEDENCE)
Example #7
0
def test_invalid_wheel_package_name(package_name):
    with pytest.raises(WheelPackage.InvalidPackage):
        WheelPackage(package_name)
Example #8
0
 def wheel_package(version):
     return WheelPackage('file:///tmp/setuptools-%s-py2.py3-none-any.whl' %
                         version)