[Distutils] subway setup.py failure
Phillip J. Eby
pje at telecommunity.com
Wed Nov 16 19:42:39 CET 2005
At 11:57 AM 11/16/2005 -0600, Ian Bicking wrote:
>Robin Becker wrote:
> > I'm getting this strangness from the subway setup script.
>
>SourceForge just changed there download pages, I think. After years of
>non-action, now they change. Blast you SourceForge!
Here's a patch that fixes it, and should also be compatible with the old
way if they change it back. As you can see, they significantly changed the
original page format, and also the HTML syntax of their "use_mirror" URLs.
Index: setuptools/package_index.py
===================================================================
--- setuptools/package_index.py (revision 41401)
+++ setuptools/package_index.py (working copy)
@@ -463,16 +463,14 @@
return self._download_svn(url, filename)
# Check for a SourceForge header
elif sf_url:
- if re.search(r'^<HTML><HEAD>', line, re.I):
- continue # skip first line
- elif re.search(r'<TITLE>Select a Mirror for File:',line):
- # Sourceforge mirror page
- page = file.read()
- file.close()
+ page = ''.join(list(file))
+ if '?use_mirror=' in page:
+ file.close();
os.unlink(filename)
return self._download_sourceforge(url, page, tmpdir)
break # not an index page
file.close()
+ os.unlink(filename)
raise DistutilsError("Unexpected HTML page found at "+url)
def _download_svn(self, url, filename):
@@ -490,12 +488,14 @@
def warn(self, msg, *args):
log.warn(msg, *args)
+
+
def _download_sourceforge(self, source_url, sf_page, tmpdir):
"""Download package from randomly-selected SourceForge mirror"""
self.debug("Processing SourceForge mirror page")
- mirror_regex = re.compile(r'HREF=(/.*?\?use_mirror=[^>]*)')
+ mirror_regex = re.compile(r'HREF="?(/.*?\?use_mirror=[^">]*)', re.I)
urls = [m.group(1) for m in mirror_regex.finditer(sf_page)]
if not urls:
raise DistutilsError(
More information about the Distutils-SIG
mailing list