Attached is a patch so it can install from Sourceforge Download pages, choosing a random mirror. Sadly I find the file I want to install from SF doesn't include version information in its setup file, so it gets the version 0.0.0. Bah. It's an abandoned package anyway (zpt.sf.net), but the up-to-date Zope version hasn't *quite* been separately distributed (though I guess it's possible to build the package from the Zope sources). -- Ian Bicking / ianb@colorstudy.com / http://blog.ianbicking.org --- orig/setuptools-0.3a2/easy_install.py 2005-05-29 18:01:42.000000000 -0500 +++ easy_install.py 2005-05-29 20:40:34.734190272 -0500 @@ -464,14 +464,20 @@ def _download_html(self, url, headers, filename): - # Check if it is a subversion index page: + sf_url = url.startswith('http://prdownloads.') file = open(filename) for line in file: if line.strip(): + # Check if it is a subversion index page: if re.search(r'<title>Revision \d+:', line): file.close() os.unlink(filename) return self._download_svn(url, filename) + elif sf_url and re.search(r'^<HTML><HEAD>', line, re.I): + continue + elif sf_url and re.search(r'\s*<TITLE>Select a Mirror for File: ', line): + # Sourceforge mirror page: + return self._download_sourceforge(url, file.read()) else: break # not an index page file.close() @@ -482,8 +488,33 @@ os.system("svn checkout -q %s %s" % (url, filename)) return filename + def _download_sourceforge(self, source_url, sf_page): + """ + Return a (randomly-selected) (scheme URL) for downloading the + package, given the SourceForge mirror-selection page. + """ + import random + import urlparse + import urllib + mirror_regex = re.compile(r'HREF=(/.*?\?use_mirror=[^>]*)') + urls = [m.group(1) for m in mirror_regex.finditer(sf_page)] + if not urls: + raise RuntimeError( + "URL appears to be a Sourceforge mirror page, but no URLs found") + url = urlparse.urljoin(source_url, random.choice(urls)) + f = urllib.urlopen(url) + mirror_page = f.read() + f.close() + match = re.search(r'<META HTTP-EQUIV="refresh" content=".*?URL=(.*?)"', mirror_page) + if not match: + raise RuntimeError( + 'No META HTTP-EQUIV="refresh" found in Sourceforge page at %s' % url) + download_url = match.group(1) + scheme = URL_SCHEME(download_url) + print download_url + return self._download_url(scheme.group(1), download_url) - +