def _get_custom_interpreter(implementation: Optional[str] = None, version: Optional[str] = None) -> str: if implementation is None: implementation = interpreter_name() if version is None: version = interpreter_version() return f"{implementation}{version}"
def _get_custom_interpreter(implementation=None, version=None): # type: (Optional[str], Optional[str]) -> str if implementation is None: implementation = interpreter_name() if version is None: version = interpreter_version() return "{}{}".format(implementation, version)
def _get_cache_path_parts(self, link): # type: (Link) -> List[str] """Get parts of part that must be os.path.joined with cache_dir """ # We want to generate an url to use as our cache key, we don't want to # just re-use the URL because it might have other items in the fragment # and we don't care about those. key_parts = {"url": link.url_without_fragment} if link.hash_name is not None and link.hash is not None: key_parts[link.hash_name] = link.hash if link.subdirectory_fragment: key_parts["subdirectory"] = link.subdirectory_fragment # Include interpreter name, major and minor version in cache key # to cope with ill-behaved sdists that build a different wheel # depending on the python version their setup.py is being run on, # and don't encode the difference in compatibility tags. # https://github.com/pypa/pip/issues/7296 key_parts["interpreter_name"] = interpreter_name() key_parts["interpreter_version"] = interpreter_version() # Encode our key url with sha224, we'll use this because it has similar # security properties to sha256, but with a shorter total output (and # thus less secure). However the differences don't make a lot of # difference for our use case here. hashed = _hash_dict(key_parts) # We want to nest the directories some to prevent having a ton of top # level directories where we might run out of sub directories on some # FS. parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]] return parts
def get_supported( version=None, # type: Optional[str] platform=None, # type: Optional[str] impl=None, # type: Optional[str] abi=None # type: Optional[str] ): # type: (...) -> List[Tag] """Return a list of supported tags for each version specified in `versions`. :param version: a string version, of the form "33" or "32", or None. The version will be assumed to support our ABI. :param platform: specify the exact platform you want valid tags for, or None. If None, use the local system platform. :param impl: specify the exact implementation you want valid tags for, or None. If None, use the local interpreter impl. :param abi: specify the exact abi you want valid tags for, or None. If None, use the local interpreter abi. """ supported = [] # type: List[Tag] python_version = None # type: Optional[PythonVersion] if version is not None: python_version = _get_python_version(version) interpreter = _get_custom_interpreter(impl, version) abis = None # type: Optional[List[str]] if abi is not None: abis = [abi] platforms = None # type: Optional[List[str]] if platform is not None: platforms = _get_custom_platforms(platform) is_cpython = (impl or interpreter_name()) == "cp" if is_cpython: supported.extend( cpython_tags( python_version=python_version, abis=abis, platforms=platforms, )) else: supported.extend( generic_tags( interpreter=interpreter, abis=abis, platforms=platforms, )) supported.extend( compatible_tags( python_version=python_version, interpreter=interpreter, platforms=platforms, )) return supported
def get_supported( version: Optional[str] = None, platforms: Optional[List[str]] = None, impl: Optional[str] = None, abis: Optional[List[str]] = None, ) -> List[Tag]: """Return a list of supported tags for each version specified in `versions`. :param version: a string version, of the form "33" or "32", or None. The version will be assumed to support our ABI. :param platform: specify a list of platforms you want valid tags for, or None. If None, use the local system platform. :param impl: specify the exact implementation you want valid tags for, or None. If None, use the local interpreter impl. :param abis: specify a list of abis you want valid tags for, or None. If None, use the local interpreter abi. """ supported: List[Tag] = [] python_version: Optional["PythonVersion"] = None if version is not None: python_version = _get_python_version(version) interpreter = _get_custom_interpreter(impl, version) platforms = _expand_allowed_platforms(platforms) is_cpython = (impl or interpreter_name()) == "cp" if is_cpython: supported.extend( cpython_tags( python_version=python_version, abis=abis, platforms=platforms, ) ) else: supported.extend( generic_tags( interpreter=interpreter, abis=abis, platforms=platforms, ) ) supported.extend( compatible_tags( python_version=python_version, interpreter=interpreter, platforms=platforms, ) ) return supported
def abi_tag_unicode(self, flags, config_vars): """ Used to test ABI tags, verify correct use of the `u` flag """ import pip._internal.pep425tags config_vars.update({'SOABI': None}) base = interpreter_name() + interpreter_version() if sys.version_info >= (3, 8): # Python 3.8 removes the m flag, so don't look for it. flags = flags.replace('m', '') if sys.version_info < (3, 3): config_vars.update({'Py_UNICODE_SIZE': 2}) mock_gcf = self.mock_get_config_var(**config_vars) with patch('pip._internal.pep425tags.sysconfig.get_config_var', mock_gcf): abi_tag = pip._internal.pep425tags.get_abi_tag() assert abi_tag == base + flags config_vars.update({'Py_UNICODE_SIZE': 4}) mock_gcf = self.mock_get_config_var(**config_vars) with patch('pip._internal.pep425tags.sysconfig.get_config_var', mock_gcf): abi_tag = pip._internal.pep425tags.get_abi_tag() assert abi_tag == base + flags + 'u' else: # On Python >= 3.3, UCS-4 is essentially permanently enabled, and # Py_UNICODE_SIZE is None. SOABI on these builds does not include # the 'u' so manual SOABI detection should not do so either. config_vars.update({'Py_UNICODE_SIZE': None}) mock_gcf = self.mock_get_config_var(**config_vars) with patch('pip._internal.pep425tags.sysconfig.get_config_var', mock_gcf): abi_tag = pip._internal.pep425tags.get_abi_tag() assert abi_tag == base + flags
interpreter = _get_custom_interpreter(impl, version) <<<<<<< HEAD platforms = _expand_allowed_platforms(platforms) ======= abis = None # type: Optional[List[str]] if abi is not None: abis = [abi] platforms = None # type: Optional[List[str]] if platform is not None: platforms = _get_custom_platforms(platform) >>>>>>> 74c061954d5e927be4caafbd793e96a50563c265 is_cpython = (impl or interpreter_name()) == "cp" if is_cpython: supported.extend( cpython_tags( python_version=python_version, abis=abis, platforms=platforms, ) ) else: supported.extend( generic_tags( interpreter=interpreter, abis=abis, platforms=platforms, )
def _get_custom_interpreter(implementation=None, version=None): # type: (Optional[str], Optional[str]) -> str if implementation is None: implementation = interpreter_name() if version is None: