# Buggy code
def _link_package_versions(self, link, search_name):
    """
    Return an iterable of triples (pkg_resources_version_key,
    link, python_version) that can be extracted from the given
    link.

    Meant to be overridden by subclasses, not called by clients.
    """
    if link.egg_fragment:
        egg_info = link.egg_fragment
    else:
        egg_info, ext = link.splitext()
        if not ext:
            if link not in self.logged_links:
                logger.debug("Skipping link %s; not a file" % link)
                self.logged_links.add(link)
            return []
        if egg_info.endswith(".tar"):
            # Special double-extension case:
            egg_info = egg_info[:-4]
            ext = ".tar" + ext
        if ext not in (".tar.gz", ".tar.bz2", ".tar", ".tgz", ".zip"):
            if link not in self.logged_links:
                logger.debug(
                    "Skipping link %s; unknown archive format: %s" % (link, ext)
                )
                self.logged_links.add(link)
            return []
    version = self._egg_info_matches(egg_info, search_name, link)
    if version is None:
        logger.debug(
            "Skipping link %s; wrong project name (not %s)" % (link, search_name)
        )
        return []
    match = self._py_version_re.search(version)
    if match:
        version = version[: match.start()]
        py_version = match.group(1)
        if py_version != sys.version[:3]:
            logger.debug("Skipping %s because Python version is incorrect" % link)
            return []
    logger.debug("Found link %s, version: %s" % (link, version))
    return [(pkg_resources.parse_version(version), link, version)]


# Traceback (IOError)
zyv@mypride:~/Desktop$ pip install pygame
Downloading/unpacking pygame
Downloading pygame-1.9.1release-py2.6-macosx10.5.zip (10.8Mb): 10.8Mb downloaded
Running setup.py egg_info for package pygame
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/home/zyv/Desktop/build/pygame/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "<string>", line 14, in <module>

IOError: [Errno 2] No such file or directory: '/home/zyv/Desktop/build/pygame/setup.py'

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/zyv/.pip/pip.log

# Fixed code
def _link_package_versions(self, link, search_name):
    """
    Return an iterable of triples (pkg_resources_version_key,
    link, python_version) that can be extracted from the given
    link.

    Meant to be overridden by subclasses, not called by clients.
    """
    if link.egg_fragment:
        egg_info = link.egg_fragment
    else:
        egg_info, ext = link.splitext()
        if not ext:
            if link not in self.logged_links:
                logger.debug("Skipping link %s; not a file" % link)
                self.logged_links.add(link)
            return []
        if egg_info.endswith(".tar"):
            # Special double-extension case:
            egg_info = egg_info[:-4]
            ext = ".tar" + ext
        if ext not in (".tar.gz", ".tar.bz2", ".tar", ".tgz", ".zip"):
            if link not in self.logged_links:
                logger.debug(
                    "Skipping link %s; unknown archive format: %s" % (link, ext)
                )
                self.logged_links.add(link)
            return []
        if "macosx10" in link.path and ext in (".zip"):
            if link not in self.logged_links:
                logger.debug("Skipping link %s; macosx10 one" % (link))
                self.logged_links.add(link)
            return []
    version = self._egg_info_matches(egg_info, search_name, link)
    if version is None:
        logger.debug(
            "Skipping link %s; wrong project name (not %s)" % (link, search_name)
        )
        return []
    match = self._py_version_re.search(version)
    if match:
        version = version[: match.start()]
        py_version = match.group(1)
        if py_version != sys.version[:3]:
            logger.debug("Skipping %s because Python version is incorrect" % link)
            return []
    logger.debug("Found link %s, version: %s" % (link, version))
    return [(pkg_resources.parse_version(version), link, version)]