Ejemplo n.º 1
0
def distribution_compatible(dist, supported_tags=None):
  """Is this distribution compatible with the given supported tags?

  :param supported_tags: A list of tag tuples specifying which tags are supported
    by the platform in question; defaults to the current interpreter's supported tags.
  :returns: True if the distribution is compatible, False if it is unrecognized or incompatible.
  """

  filename, ext = os.path.splitext(os.path.basename(dist.location))
  if ext.lower() != '.whl':
    # This supports resolving pex's own vendored distributions which are vendored in directory
    # directory with the project name (`pip/` for pip) and not the corresponding wheel name
    # (`pip-19.3.1-py2.py3-none-any.whl/` for pip). Pex only vendors universal wheels for all
    # platforms it supports at buildtime and runtime so this is always safe.
    return True

  if supported_tags is None:
    supported_tags = get_supported()

  try:
    name_, raw_version_, py_tag, abi_tag, arch_tag = filename.rsplit('-', 4)
  except ValueError:
    return False

  def _iter_tags():
    for py in py_tag.split('.'):
      for abi in abi_tag.split('.'):
        for arch in arch_tag.split('.'):
          yield (py, abi, arch)

  return not frozenset(supported_tags).isdisjoint(frozenset(_iter_tags()))
Ejemplo n.º 2
0
 def default(interpreter=None, supported_tags=None):
     interpreter = interpreter or PythonInterpreter.get()
     supported_tags = supported_tags or get_supported()
     whl_translator = WheelTranslator(supported_tags=supported_tags)
     egg_translator = EggTranslator(supported_tags=supported_tags)
     source_translator = SourceTranslator(interpreter=interpreter)
     return ChainedTranslator(whl_translator, egg_translator,
                              source_translator)
Ejemplo n.º 3
0
 def __init__(self,
              interpreter=PythonInterpreter.get(),
              supported_tags=None,
              use_2to3=False,
              installer_impl=WheelInstaller):
     self._supported_tags = supported_tags or get_supported()
     self._interpreter = interpreter
     self._installer_impl = installer_impl
     self._use_2to3 = use_2to3
Ejemplo n.º 4
0
def distribution_compatible(dist, supported_tags=None):
  """Is this distribution compatible with the given interpreter/platform combination?

  :param supported_tags: A list of tag tuples specifying which tags are supported
    by the platform in question.
  :returns: True if the distribution is compatible, False if it is unrecognized or incompatible.
  """
  if supported_tags is None:
    supported_tags = get_supported()
  package = Package.from_href(dist.location)
  if not package:
    return False
  return package.compatible(supported_tags)
Ejemplo n.º 5
0
    def test_manylinux1_tag_is_first(self):
        """
    Test that the more specific tag manylinux1 comes first.
    """
        groups = {}
        for pyimpl, abi, arch in pep425tags.get_supported():
            groups.setdefault((pyimpl, abi), []).append(arch)

        for arches in groups.values():
            if arches == ['any']:
                continue
            # Expect the most specific arch first:
            if len(arches) == 3:
                assert arches == ['manylinux1_x86_64', 'linux_x86_64', 'any']
            else:
                assert arches == ['manylinux1_x86_64', 'linux_x86_64']
Ejemplo n.º 6
0
def _get_supported(version=None, platform=None, impl=None, abi=None, force_manylinux=False):
  versions = _gen_all_compatible_versions(version) if version is not None else None
  all_supported = get_supported(
    versions=versions,
    platform=platform,
    impl=impl,
    abi=abi
  )

  def iter_all_supported():
    for supported in all_supported:
      yield supported
      python_tag, abi_tag, platform_tag = supported
      if platform_tag.startswith('linux') and force_manylinux:
        yield python_tag, abi_tag, platform_tag.replace('linux', 'manylinux1')

  return list(OrderedSet(iter_all_supported()))
Ejemplo n.º 7
0
    def supported_tags(self, interpreter=None, force_manylinux=True):
        """Returns a list of supported PEP425 tags for the current platform."""
        if interpreter and not self.is_extended:
            # N.B. If we don't get an extended platform specifier, we generate
            # all possible ABI permutations to mimic earlier pex version
            # behavior and make cross-platform resolution more intuitive.
            tags = get_supported_for_any_abi(
                platform=self.platform,
                impl=interpreter.identity.abbr_impl,
                version=interpreter.identity.impl_ver,
                force_manylinux=force_manylinux)
        else:
            tags = get_supported(platform=self.platform,
                                 impl=self.impl,
                                 version=self.version,
                                 abi=self.abi,
                                 force_manylinux=force_manylinux)

        return tags
Ejemplo n.º 8
0
 def __init__(self, package_type, supported_tags=None):
     self._package_type = package_type
     self._supported_tags = supported_tags or get_supported()