code: def _pypi_head_package(dependency):
      
      if dependency.specs:
          _, version = dependency.specs[0]
          url = BASE_PYPI_URL_WITH_VERSION.format(name=dependency.project_name, version=version)
      else:
          url = BASE_PYPI_URL.format(name=dependency.project_name)
      logger.debug("Doing HEAD requests against %s", url)
      req = request.Request(url, method='HEAD')
      try:
          response = request.urlopen(req)
      except HTTPError as http_error:
          if http_error.code == HTTP_STATUS_NOT_FOUND:
              return False
          else:
              raise
      if response.status == HTTP_STATUS_OK:
          logger.debug("%r exists in PyPI.", dependency)
          return True
      else:
          # Maybe we are getting somethink like a redirect. In this case we are only
          # warning to the user and trying to install the dependency.
          # In the worst scenery fades will fail to install it.
          logger.warning("Got a (unexpected) HTTP_STATUS=%r and reason=%r checking if %r exists",
                         response.status, response.reason, dependency)
          return True
docs: Hit pypi with a http HEAD to check if pkg_name exists.