(self, link)
return (True, version)
Determine whether a link is a candidate for installation.

        :return: A tuple (is_candidate, result), where `result` is (1) a
            version string if `is_candidate` is True, and (2) if
            `is_candidate` is False, an optional string to log the reason
            the link fails to qualify.
Determine whether a link is a candidate for installation.
Determine whether a link is a candidate for installation .
def evaluate_link(self, link):
        # type: (Link) -> Tuple[bool, Optional[Text]]
        """
        Determine whether a link is a candidate for installation.

        :return: A tuple (is_candidate, result), where `result` is (1) a
            version string if `is_candidate` is True, and (2) if
            `is_candidate` is False, an optional string to log the reason
            the link fails to qualify.
        """
        version = None
        if link.is_yanked and not self._allow_yanked:
            reason = link.yanked_reason or '<none given>'
            # Mark this as a unicode string to prevent "UnicodeEncodeError:
            # 'ascii' codec can't encode character" in Python 2 when
            # the reason contains non-ascii characters.
            return (False, u'yanked for reason: {}'.format(reason))

        if link.egg_fragment:
            egg_info = link.egg_fragment
            ext = link.ext
        else:
            egg_info, ext = link.splitext()
            if not ext:
                return (False, 'not a file')
            if ext not in SUPPORTED_EXTENSIONS:
                return (False, 'unsupported archive format: %s' % ext)
            if "binary" not in self._formats and ext == WHEEL_EXTENSION:
                reason = 'No binaries permitted for %s' % self.project_name
                return (False, reason)
            if "macosx10" in link.path and ext == '.zip':
                return (False, 'macosx10 one')
            if ext == WHEEL_EXTENSION:
                try:
                    wheel = Wheel(link.filename)
                except InvalidWheelFilename:
                    return (False, 'invalid wheel filename')
                if canonicalize_name(wheel.name) != self._canonical_name:
                    reason = 'wrong project name (not %s)' % self.project_name
                    return (False, reason)

                supported_tags = self._target_python.get_tags()
                if not wheel.supported(supported_tags):
                    # Include the wheel's tags in the reason string to
                    # simplify troubleshooting compatibility issues.
                    file_tags = wheel.get_formatted_file_tags()
                    reason = (
                        "none of the wheel's tags match: {}".format(
                            ', '.join(file_tags)
                        )
                    )
                    return (False, reason)

                version = wheel.version

        # This should be up by the self.ok_binary check, but see issue 2700.
        if "source" not in self._formats and ext != WHEEL_EXTENSION:
            return (False, 'No sources permitted for %s' % self.project_name)

        if not version:
            version = _extract_version_from_fragment(
                egg_info, self._canonical_name,
            )
        if not version:
            return (
                False, 'Missing project version for %s' % self.project_name,
            )

        match = self._py_version_re.search(version)
        if match:
            version = version[:match.start()]
            py_version = match.group(1)
            if py_version != self._target_python.py_version:
                return (False, 'Python version is incorrect')

        supports_python = _check_link_requires_python(
            link, version_info=self._target_python.py_version_info,
            ignore_requires_python=self._ignore_requires_python,
        )
        if not supports_python:
            # Return None for the reason text to suppress calling
            # _log_skipped_link().
            return (False, None)

        logger.debug('Found link %s, version: %s', link, version)

        return (True, version)
def evaluate_link ( self , link ) : # type: (Link) -> Tuple[bool, Optional[Text]] version = None if link . is_yanked and not self . _allow_yanked : reason = link . yanked_reason or '<none given>' # Mark this as a unicode string to prevent "UnicodeEncodeError: # 'ascii' codec can't encode character" in Python 2 when # the reason contains non-ascii characters. return ( False , u'yanked for reason: {}' . format ( reason ) ) if link . egg_fragment : egg_info = link . egg_fragment ext = link . ext else : egg_info , ext = link . splitext ( ) if not ext : return ( False , 'not a file' ) if ext not in SUPPORTED_EXTENSIONS : return ( False , 'unsupported archive format: %s' % ext ) if "binary" not in self . _formats and ext == WHEEL_EXTENSION : reason = 'No binaries permitted for %s' % self . project_name return ( False , reason ) if "macosx10" in link . path and ext == '.zip' : return ( False , 'macosx10 one' ) if ext == WHEEL_EXTENSION : try : wheel = Wheel ( link . filename ) except InvalidWheelFilename : return ( False , 'invalid wheel filename' ) if canonicalize_name ( wheel . name ) != self . _canonical_name : reason = 'wrong project name (not %s)' % self . project_name return ( False , reason ) supported_tags = self . _target_python . get_tags ( ) if not wheel . supported ( supported_tags ) : # Include the wheel's tags in the reason string to # simplify troubleshooting compatibility issues. file_tags = wheel . get_formatted_file_tags ( ) reason = ( "none of the wheel's tags match: {}" . format ( ', ' . join ( file_tags ) ) ) return ( False , reason ) version = wheel . version # This should be up by the self.ok_binary check, but see issue 2700. if "source" not in self . _formats and ext != WHEEL_EXTENSION : return ( False , 'No sources permitted for %s' % self . project_name ) if not version : version = _extract_version_from_fragment ( egg_info , self . _canonical_name , ) if not version : return ( False , 'Missing project version for %s' % self . project_name , ) match = self . _py_version_re . search ( version ) if match : version = version [ : match . start ( ) ] py_version = match . group ( 1 ) if py_version != self . _target_python . py_version : return ( False , 'Python version is incorrect' ) supports_python = _check_link_requires_python ( link , version_info = self . _target_python . py_version_info , ignore_requires_python = self . _ignore_requires_python , ) if not supports_python : # Return None for the reason text to suppress calling # _log_skipped_link(). return ( False , None ) logger . debug ( 'Found link %s, version: %s' , link , version ) return ( True , version )