11#!python
2+ from __future__ import print_function
3+
24"""Bootstrap setuptools installation
35
46If you want to use setuptools in your package's setup.py, just include this
1416This file can also be run as a script to install or upgrade setuptools.
1517"""
1618import sys
17- DEFAULT_VERSION = "0.6c9"
19+
20+ DEFAULT_VERSION = "0.6c11"
1821DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys .version [:3 ]
1922
2023md5_data = {
2831 'setuptools-0.6b4-py2.4.egg' : '4cb2a185d228dacffb2d17f103b3b1c4' ,
2932 'setuptools-0.6c1-py2.3.egg' : 'b3f2b5539d65cb7f74ad79127f1a908c' ,
3033 'setuptools-0.6c1-py2.4.egg' : 'b45adeda0667d2d2ffe14009364f2a4b' ,
34+ 'setuptools-0.6c10-py2.3.egg' : 'ce1e2ab5d3a0256456d9fc13800a7090' ,
35+ 'setuptools-0.6c10-py2.4.egg' : '57d6d9d6e9b80772c59a53a8433a5dd4' ,
36+ 'setuptools-0.6c10-py2.5.egg' : 'de46ac8b1c97c895572e5e8596aeb8c7' ,
37+ 'setuptools-0.6c10-py2.6.egg' : '58ea40aef06da02ce641495523a0b7f5' ,
38+ 'setuptools-0.6c11-py2.3.egg' : '2baeac6e13d414a9d28e7ba5b5a596de' ,
39+ 'setuptools-0.6c11-py2.4.egg' : 'bd639f9b0eac4c42497034dec2ec0c2b' ,
40+ 'setuptools-0.6c11-py2.5.egg' : '64c94f3bf7a72a13ec83e0b24f2749b2' ,
41+ 'setuptools-0.6c11-py2.6.egg' : 'bfa92100bd772d5a213eedd356d64086' ,
3142 'setuptools-0.6c2-py2.3.egg' : 'f0064bf6aa2b7d0f3ba0b43f20817c27' ,
3243 'setuptools-0.6c2-py2.4.egg' : '616192eec35f47e8ea16cd6a122b7277' ,
3344 'setuptools-0.6c3-py2.3.egg' : 'f181fa125dfe85a259c9cd6f1d7b78fa' ,
@@ -62,10 +73,10 @@ def _validate_md5(egg_name, data):
6273 if egg_name in md5_data :
6374 digest = md5 (data ).hexdigest ()
6475 if digest != md5_data [egg_name ]:
65- print >> sys . stderr , (
76+ print ( (
6677 "md5 validation of %s failed! (Possible download problem?)"
6778 % egg_name
68- )
79+ ), file = sys . stderr )
6980 sys .exit (2 )
7081 return data
7182
@@ -95,20 +106,20 @@ def do_download():
95106 return do_download ()
96107 try :
97108 pkg_resources .require ("setuptools>=" + version ); return
98- except pkg_resources .VersionConflict , e :
109+ except pkg_resources .VersionConflict as e :
99110 if was_imported :
100- print >> sys . stderr , (
111+ print ( (
101112 "The required version of setuptools (>=%s) is not available, and\n "
102113 "can't be installed while this script is running. Please install\n "
103114 " a more recent version first, using 'easy_install -U setuptools'."
104115 "\n \n (Currently using %r)"
105- ) % (version , e .args [0 ])
116+ ) % (version , e .args [0 ]), file = sys . stderr )
106117 sys .exit (2 )
107- else :
108- del pkg_resources , sys .modules ['pkg_resources' ] # reload ok
109- return do_download ()
110118 except pkg_resources .DistributionNotFound :
111- return do_download ()
119+ pass
120+
121+ del pkg_resources , sys .modules ['pkg_resources' ] # reload ok
122+ return do_download ()
112123
113124def download_setuptools (
114125 version = DEFAULT_VERSION , download_base = DEFAULT_URL , to_dir = os .curdir ,
@@ -121,7 +132,7 @@ def download_setuptools(
121132 with a '/'). `to_dir` is the directory where the egg will be downloaded.
122133 `delay` is the number of seconds to pause before an actual download attempt.
123134 """
124- import urllib2 , shutil
135+ import urllib . request , urllib . error , urllib . parse , shutil
125136 egg_name = "setuptools-%s-py%s.egg" % (version ,sys .version [:3 ])
126137 url = download_base + egg_name
127138 saveto = os .path .join (to_dir , egg_name )
@@ -147,7 +158,7 @@ def download_setuptools(
147158 version , download_base , delay , url
148159 ); from time import sleep ; sleep (delay )
149160 log .warn ("Downloading %s" , url )
150- src = urllib2 .urlopen (url )
161+ src = urllib . request .urlopen (url )
151162 # Read/write all in one block, so we don't create a corrupt file
152163 # if the download is interrupted.
153164 data = _validate_md5 (egg_name , src .read ())
@@ -208,10 +219,10 @@ def main(argv, version=DEFAULT_VERSION):
208219 os .unlink (egg )
209220 else :
210221 if setuptools .__version__ == '0.0.1' :
211- print >> sys . stderr , (
222+ print ( (
212223 "You have an obsolete version of setuptools installed. Please\n "
213224 "remove it from your system entirely before rerunning this script."
214- )
225+ ), file = sys . stderr )
215226 sys .exit (2 )
216227
217228 req = "setuptools>=" + version
@@ -230,8 +241,8 @@ def main(argv, version=DEFAULT_VERSION):
230241 from setuptools .command .easy_install import main
231242 main (argv )
232243 else :
233- print "Setuptools version" ,version ,"or greater has been installed."
234- print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
244+ print ( "Setuptools version" ,version ,"or greater has been installed." )
245+ print ( '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' )
235246
236247def update_md5 (filenames ):
237248 """Update our built-in md5 registry"""
@@ -244,7 +255,7 @@ def update_md5(filenames):
244255 md5_data [base ] = md5 (f .read ()).hexdigest ()
245256 f .close ()
246257
247- data = [" %r: %r,\n " % it for it in md5_data .items ()]
258+ data = [" %r: %r,\n " % it for it in list ( md5_data .items () )]
248259 data .sort ()
249260 repl = "" .join (data )
250261
@@ -254,7 +265,7 @@ def update_md5(filenames):
254265
255266 match = re .search ("\n md5_data = {\n ([^}]+)}" , src )
256267 if not match :
257- print >> sys . stderr , "Internal error!"
268+ print ( "Internal error!" , file = sys . stderr )
258269 sys .exit (2 )
259270
260271 src = src [:match .start (1 )] + repl + src [match .end (1 ):]
0 commit comments