def get_tags(self): # type: () -> List[Pep425Tag] """ Return the supported PEP 425 tags to check wheel candidates against. The tags are returned in order of preference (most preferred first). """ if self._valid_tags is None: # Pass versions=None if no py_version_info was given since # versions=None uses special default logic. py_version_info = self._given_py_version_info if py_version_info is None: versions = None else: versions = [version_info_to_nodot(py_version_info)] tags = get_supported( versions=versions, platform=self.platform, abi=self.abi, impl=self.implementation, ) self._valid_tags = tags return self._valid_tags
def get_tags(self): """ Return the supported tags to check wheel candidates against. """ if self._valid_tags is None: # Pass versions=None if no py_version_info was given since # versions=None uses special default logic. py_version_info = self._given_py_version_info if py_version_info is None: versions = None else: versions = [version_info_to_nodot(py_version_info)] tags = get_supported( versions=versions, platform=self.platform, abi=self.abi, impl=self.implementation, ) self._valid_tags = tags return self._valid_tags
# type: () -> List[Tag] >>>>>>> development """ Return the supported PEP 425 tags to check wheel candidates against. The tags are returned in order of preference (most preferred first). """ if self._valid_tags is None: # Pass versions=None if no py_version_info was given since # versions=None uses special default logic. py_version_info = self._given_py_version_info if py_version_info is None: <<<<<<< HEAD versions = None else: versions = [version_info_to_nodot(py_version_info)] tags = get_supported( versions=versions, ======= version = None else: version = version_info_to_nodot(py_version_info) tags = get_supported( version=version, >>>>>>> development platform=self.platform, abi=self.abi, impl=self.implementation, )
def test_version_info_to_nodot(version_info, expected): actual = pep425tags.version_info_to_nodot(version_info) assert actual == expected
def create( cls, find_links, # type: List[str] index_urls, # type: List[str] allow_all_prereleases=False, # type: bool trusted_hosts=None, # type: Optional[Iterable[str]] session=None, # type: Optional[PipSession] format_control=None, # type: Optional[FormatControl] platform=None, # type: Optional[str] py_version_info=None, # type: Optional[Tuple[int, ...]] abi=None, # type: Optional[str] implementation=None, # type: Optional[str] prefer_binary=False, # type: bool ignore_requires_python=None, # type: Optional[bool] ): # type: (...) -> PackageFinder """Create a PackageFinder. :param trusted_hosts: Domains that we won't emit warnings for when not using HTTPS. :param session: The Session to use to make requests. :param format_control: A FormatControl object or None. Used to control the selection of source packages / binary packages when consulting the index and links. :param platform: A string or None. If None, searches for packages that are supported by the current system. Otherwise, will find packages that can be built on the platform passed in. These packages will only be downloaded for distribution: they will not be built locally. :param py_version_info: An optional tuple of ints representing the Python version information to use (e.g. `sys.version_info[:3]`). This can have length 1, 2, or 3. This is used to construct the value passed to pep425tags.py's get_supported() function. :param abi: A string or None. This is passed directly to pep425tags.py in the get_supported() method. :param implementation: A string or None. This is passed directly to pep425tags.py in the get_supported() method. :param prefer_binary: Whether to prefer an old, but valid, binary dist over a new source dist. :param ignore_requires_python: Whether to ignore incompatible "Requires-Python" values in links. Defaults to False. """ if session is None: raise TypeError( "PackageFinder.create() missing 1 required keyword argument: " "'session'") # Build find_links. If an argument starts with ~, it may be # a local file relative to a home directory. So try normalizing # it and if it exists, use the normalized version. # This is deliberately conservative - it might be fine just to # blindly normalize anything starting with a ~... built_find_links = [] # type: List[str] for link in find_links: if link.startswith('~'): new_link = normalize_path(link) if os.path.exists(new_link): link = new_link built_find_links.append(link) secure_origins = [("*", host, "*") for host in (trusted_hosts if trusted_hosts else []) ] # type: List[SecureOrigin] if py_version_info: versions = [version_info_to_nodot(py_version_info)] else: versions = None py_version_info = normalize_version_info(py_version_info) # The valid tags to check potential found wheel candidates against valid_tags = get_supported( versions=versions, platform=platform, abi=abi, impl=implementation, ) candidate_evaluator = CandidateEvaluator( valid_tags=valid_tags, prefer_binary=prefer_binary, allow_all_prereleases=allow_all_prereleases, py_version_info=py_version_info, ignore_requires_python=ignore_requires_python, ) # If we don't have TLS enabled, then WARN if anyplace we're looking # relies on TLS. if not HAS_TLS: for link in itertools.chain(index_urls, built_find_links): parsed = urllib_parse.urlparse(link) if parsed.scheme == "https": logger.warning( "pip is configured with locations that require " "TLS/SSL, however the ssl module in Python is not " "available.") break return cls( candidate_evaluator=candidate_evaluator, find_links=built_find_links, index_urls=index_urls, secure_origins=secure_origins, session=session, format_control=format_control, )