2929except ImportError :
3030 USER_SITE = None
3131
32- DEFAULT_VERSION = "1.1"
32+ DEFAULT_VERSION = "1.1.1 "
3333DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
3434
3535def _python_cmd (* args ):
@@ -254,14 +254,18 @@ def get_best_downloader():
254254 return dl
255255
256256def download_setuptools (version = DEFAULT_VERSION , download_base = DEFAULT_URL ,
257- to_dir = os .curdir , delay = 15 ):
257+ to_dir = os .curdir , delay = 15 ,
258+ downloader_factory = get_best_downloader ):
258259 """Download setuptools from a specified location and return its filename
259260
260261 `version` should be a valid setuptools version number that is available
261262 as an egg for download under the `download_base` URL (which should end
262263 with a '/'). `to_dir` is the directory where the egg will be downloaded.
263264 `delay` is the number of seconds to pause before an actual download
264265 attempt.
266+
267+ ``downloader_factory`` should be a function taking no arguments and
268+ returning a function for downloading a URL to a target.
265269 """
266270 # making sure we use the absolute path
267271 to_dir = os .path .abspath (to_dir )
@@ -270,7 +274,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
270274 saveto = os .path .join (to_dir , tgz_name )
271275 if not os .path .exists (saveto ): # Avoid repeated downloads
272276 log .warn ("Downloading %s" , url )
273- downloader = get_best_downloader ()
277+ downloader = downloader_factory ()
274278 downloader (url , saveto )
275279 return os .path .realpath (saveto )
276280
@@ -346,14 +350,20 @@ def _parse_args():
346350 '--download-base' , dest = 'download_base' , metavar = "URL" ,
347351 default = DEFAULT_URL ,
348352 help = 'alternative URL from where to download the setuptools package' )
353+ parser .add_option (
354+ '--insecure' , dest = 'downloader_factory' , action = 'store_const' ,
355+ const = lambda : download_file_insecure , default = get_best_downloader ,
356+ help = 'Use internal, non-validating downloader'
357+ )
349358 options , args = parser .parse_args ()
350359 # positional arguments are ignored
351360 return options
352361
353362def main (version = DEFAULT_VERSION ):
354363 """Install or upgrade setuptools and EasyInstall"""
355364 options = _parse_args ()
356- tarball = download_setuptools (download_base = options .download_base )
365+ tarball = download_setuptools (download_base = options .download_base ,
366+ downloader_factory = options .downloader_factory )
357367 return _install (tarball , _build_install_args (options ))
358368
359369if __name__ == '__main__' :
0 commit comments