Jason R. Coombs  committed 2f2bfb6 now takes a --insecure argument to bypass the secure downloaders. download_setuptools also now accepts a new keyword argument 'download_factory', enabling programmitic invocation to customize the downloader resolution. Fixes #75. Thanks to Pablo Algarvio for the report and suggestions.

  • Participants
  • Parent commits d943b67
  • Branches default

Comments (0)

Files changed (3)

+* Issue #75: Add ``--insecure`` option to to accommodate
+  environments where a trusted SSL connection cannot be validated.


 * Marc Abramowitz
 * Martin von Löwis
 * Noufal Ibrahim
+* Pedro Algarvio
 * Pete Hollobon
 * Phillip J. Eby
 * Philip Jenvey
             return dl
 def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
-                        to_dir=os.curdir, delay=15):
+                        to_dir=os.curdir, delay=15,
+                        downloader_factory=get_best_downloader):
     """Download setuptools from a specified location and return its filename
     `version` should be a valid setuptools version number that is available
     with a '/'). `to_dir` is the directory where the egg will be downloaded.
     `delay` is the number of seconds to pause before an actual download
+    ``downloader_factory`` should be a function taking no arguments and
+    returning a function for downloading a URL to a target.
     # making sure we use the absolute path
     to_dir = os.path.abspath(to_dir)
     saveto = os.path.join(to_dir, tgz_name)
     if not os.path.exists(saveto):  # Avoid repeated downloads
         log.warn("Downloading %s", url)
-        downloader = get_best_downloader()
+        downloader = downloader_factory()
         downloader(url, saveto)
     return os.path.realpath(saveto)
         '--download-base', dest='download_base', metavar="URL",
         help='alternative URL from where to download the setuptools package')
+    parser.add_option(
+        '--insecure', dest='downloader_factory', action='store_const',
+        const=lambda: download_file_insecure, default=get_best_downloader,
+        help='Use internal, non-validating downloader'
+    )
     options, args = parser.parse_args()
     # positional arguments are ignored
     return options
 def main(version=DEFAULT_VERSION):
     """Install or upgrade setuptools and EasyInstall"""
     options = _parse_args()
-    tarball = download_setuptools(download_base=options.download_base)
+    tarball = download_setuptools(download_base=options.download_base,
+        downloader_factory=options.downloader_factory)
     return _install(tarball, _build_install_args(options))
 if __name__ == '__main__':