summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xEasyInstall.txt12
-rwxr-xr-xsetuptools/package_index.py44
2 files changed, 34 insertions, 22 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt
index 2c0a6e11..9ffa9922 100755
--- a/EasyInstall.txt
+++ b/EasyInstall.txt
@@ -355,6 +355,14 @@ The above example would then allow downloads only from hosts in the
``python.org`` and ``myintranet.example.com`` domains, unless overridden on the
command line.
+Note that if you want to allow downloads from Sourceforge, you need to enable
+the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated
+as if they had this hostname. (If a download attempt from
+``dl.sourceforge.net`` fails, it is automatically retried using a randomly
+selected mirror IP drawn from the ``sf-mirrors.telecommunity.com`` round-robin
+addres. The IP's, however, are not checked against the ``--allow-hosts``
+mask.)
+
Installing on Un-networked Machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1198,6 +1206,10 @@ Release Notes/Change History
* Fixed not recogninzing ``win32.exe`` installers that included a custom
bitmap.
+ * Fixed SF downloads aborting when a SF mirror returns an HTML page when it
+ should've returned a 404. Fall back to ``sf-mirrors.telecommunity.com``
+ round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work.
+
0.6c3
* You once again use "python -m easy_install" with Python 2.4 and above.
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 837eff19..78e89daf 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -533,7 +533,6 @@ class PackageIndex(Environment):
dl_blocksize = 8192
def _download_to(self, url, filename):
- self.url_ok(url,True) # raises error if not allowed
self.info("Downloading %s", url)
# Download the file
fp, tfp, info = None, None, None
@@ -572,9 +571,18 @@ class PackageIndex(Environment):
def reporthook(self, url, filename, blocknum, blksize, size):
pass # no-op
- def retry_sf_download(self, url, filename):
+
+ def _attempt_download(self, url, filename):
+ headers = self._download_to(url, filename)
+ if 'html' in headers['content-type'].lower():
+ return self._download_html(url, headers, filename)
+ else:
+ return filename
+
+ def _retry_sf_download(self, url, filename):
+ self.url_ok(url, True) # raises error if not allowed
try:
- return self._download_to(url, filename)
+ return self._attempt_download(url, filename)
except (KeyboardInterrupt,SystemExit):
raise
except:
@@ -588,7 +596,9 @@ class PackageIndex(Environment):
self.warn("Download failed: %s", sys.exc_info()[1])
url = urlparse.urlunparse((scheme, mirror, path, param, '', frag))
try:
- return self._download_to(url, filename)
+ return self._attempt_download(url, filename)
+ except (KeyboardInterrupt,SystemExit):
+ raise
except:
_sf_mirrors.remove(mirror) # don't retry the same mirror
mirror = get_sf_ip()
@@ -603,16 +613,6 @@ class PackageIndex(Environment):
-
-
-
-
-
-
-
-
-
-
def open_url(self, url):
if url.startswith('file:'):
return local_open(url)
@@ -648,16 +648,16 @@ class PackageIndex(Environment):
elif scheme=='file':
return urllib2.url2pathname(urlparse.urlparse(url)[2])
else:
- headers = self.retry_sf_download(url, filename)
- if 'html' in headers['content-type'].lower():
- return self._download_html(url, headers, filename, tmpdir)
- else:
- return filename
+ return self._retry_sf_download(url, filename)
+
+
+
+
def scan_url(self, url):
self.process_url(url, True)
- def _download_html(self, url, headers, filename, tmpdir):
+ def _download_html(self, url, headers, filename):
file = open(filename)
for line in file:
if line.strip():
@@ -700,7 +700,8 @@ _sf_mirrors = []
def get_sf_ip():
if not _sf_mirrors:
try:
- _sf_mirrors[:] = socket.gethostbyname_ex('dl.sourceforge.net')[-1]
+ _sf_mirrors[:] = socket.gethostbyname_ex(
+ 'sf-mirrors.telecommunity.com')[-1]
except socket.error:
# DNS-bl0ck1n9 f1r3w4llz sUx0rs!
_sf_mirrors[:] = ['dl.sourceforge.net']
@@ -734,5 +735,4 @@ def local_open(url):
-
# this line is a kludge to keep the trailing blank lines for pje's editor