Changeset 5755
- Timestamp:
- 11/23/08 15:13:35 (2 months ago)
- Files:
-
- branches/1.0/tools/tgsetup.py (modified) (13 diffs)
- branches/1.1/tools/tgsetup.py (modified) (14 diffs)
- branches/1.5/tools/tgsetup.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/tools/tgsetup.py
r5753 r5755 29 29 # this is the default version of setuptools, not TG 30 30 DEFAULT_VERSION = "0.6c9" 31 DEFAULT_URL = "http:// cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3]31 DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] 32 32 33 33 md5_data = { … … 59 59 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', 60 60 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', 61 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', 61 62 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', 62 63 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', … … 68 69 69 70 import sys, os 71 try: from hashlib import md5 72 except ImportError: from md5 import md5 70 73 71 74 # TGBEGIN 72 75 win32 = """ 73 The recommended Python for TurboGears is Python 2.5.2. You can download74 it here:76 The recommended Python for TurboGears 1.0 is Python 2.5.2. 77 You can download it here: 75 78 76 79 http://www.python.org/ftp/python/2.5.2/python-2.5.2.msi … … 78 81 79 82 darwin = """ 80 The recommended Python for TurboGears is Python 2.5.2. You can download81 a Universal build here:83 The recommended Python for TurboGears 1.0 is Python 2.5.2. 84 You can download a Universal build here: 82 85 83 86 http://www.python.org/ftp/python/2.5.2/python-2.5.2-macosx.dmg … … 85 88 86 89 other = """ 87 The recommended Python for TurboGears is Python 2.5.2. This version of88 Python is often available in your operating system's native package 89 format (via apt-get or yum, for instance). You can also easily build 90 Python from source on Unix-like systems. Here is the source download 91 link for Python:90 The recommended Python for TurboGears 1.0 is Python 2.5.2. 91 This version of Python is often available in your operating system's 92 native package format (via apt-get or yum, for instance). 93 You can also easily build Python from source on Unix-like systems. 94 Here is the source download link for Python: 92 95 93 96 http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2 … … 139 142 140 143 def check_python(): 141 if sys.version_info < (2, 3):142 print "Python 2.3 or higher is required to run TurboGears 1.0. x."144 if sys.version_info < (2, 3): 145 print "Python 2.3 or higher is required to run TurboGears 1.0." 143 146 144 147 if not get_python(): 145 148 sys.exit(1) 146 149 147 elif sys.version_info < (2, 4):148 print "TurboGears 1.0 .xsupports Python 2.3, but 2.4 is strongly recommended."150 elif sys.version_info < (2, 4): 151 print "TurboGears 1.0 supports Python 2.3, but 2.4 is strongly recommended." 149 152 150 153 if not get_python(): … … 154 157 print "You can rerun the installer once you have an updated Python." 155 158 sys.exit(1) 159 160 elif sys.version_info >= (2, 6): 161 print "Python 2.6 or higher is not supported by TurboGears 1.0." 162 163 if not get_python(): 164 sys.exit(1) 156 165 157 166 def check_directory(): … … 193 202 print "Beginning setuptools/EasyInstall installation and TurboGears " \ 194 203 "download\n" 195 196 204 if len(sys.argv) > 1: 197 205 args = sys.argv[1:] … … 268 276 def _validate_md5(egg_name, data): 269 277 if egg_name in md5_data: 270 from md5 import md5271 278 digest = md5(data).hexdigest() 272 279 if digest != md5_data[egg_name]: 273 280 print >>sys.stderr, ( 274 "md5 validation of %s failed! (Possible download problem?)"281 "md5 validation of %s failed! (Possible download problem?)" 275 282 % egg_name 276 283 ) 277 284 sys.exit(2) 278 285 return data 279 280 286 281 287 def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, … … 292 298 an attempt to abort the calling script. 293 299 """ 294 try: 295 import setuptools 296 if setuptools.__version__ == '0.0.1': 297 print >>sys.stderr, ( 298 "You have an obsolete version of setuptools installed. Please\n" 299 "remove it from your system entirely before rerunning this script." 300 ) 301 sys.exit(2) 302 except ImportError: 300 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules 301 def do_download(): 303 302 egg = download_setuptools(version, download_base, to_dir, download_delay) 304 303 sys.path.insert(0, egg) 305 304 import setuptools; setuptools.bootstrap_install_from = egg 306 307 import pkg_resources308 305 try: 309 pkg_resources.require("setuptools>="+version) 310 306 import pkg_resources 307 except ImportError: 308 return do_download() 309 try: 310 pkg_resources.require("setuptools>="+version); return 311 311 except pkg_resources.VersionConflict, e: 312 # XXX could we install in a subprocess here?313 print >>sys.stderr, (312 if was_imported: 313 print >>sys.stderr, ( 314 314 "The required version of setuptools (>=%s) is not available, and\n" 315 315 "can't be installed while this script is running. Please install\n" 316 " a more recent version first.\n\n(Currently using %r)" 317 ) % (version, e.args[0]) 318 sys.exit(2) 319 320 def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, 321 to_dir=os.curdir, delay = 15): 316 " a more recent version first, using 'easy_install -U setuptools'." 317 "\n\n(Currently using %r)" 318 ) % (version, e.args[0]) 319 sys.exit(2) 320 else: 321 del pkg_resources, sys.modules['pkg_resources'] # reload ok 322 return do_download() 323 except pkg_resources.DistributionNotFound: 324 return do_download() 325 326 def download_setuptools( 327 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, 328 delay = 15 329 ): 322 330 """Download setuptools from a specified location and return its filename 323 331 … … 365 373 def main(argv, version=DEFAULT_VERSION): 366 374 """Install or upgrade setuptools and EasyInstall""" 367 375 #TGBEGIN 368 376 try: 369 import setuptools370 371 except ImportError:372 egg = None373 377 try: 374 egg = download_setuptools(version, delay=0) 375 sys.path.insert(0,egg) 378 import setuptools 379 except ImportError: 380 egg = None 381 try: 382 egg = download_setuptools(version, delay=0) 383 sys.path.insert(0,egg) 384 from setuptools.command.easy_install import main 385 return main(list(argv)+[egg]) # we're done here 386 finally: 387 if egg and os.path.exists(egg): 388 os.unlink(egg) 389 except Exception, e: 390 print >>sys.stderr, ( 391 "Could not download and install setupools:\n%s\n" 392 "Please try installing setuptools manually." 393 % (str(e) or e.__class__.__name__)) 394 sys.exit(2) 395 if setuptools.__version__ == '0.0.1': 396 print >>sys.stderr, ( 397 "You have an obsolete version of setuptools installed. Please\n" 398 "remove it from your system entirely before rerunning this script." 399 ) 400 sys.exit(2) 401 #TGEND 402 403 req = "setuptools>=" + version 404 import pkg_resources 405 try: 406 pkg_resources.require(req) 407 except pkg_resources.VersionConflict: 408 try: 376 409 from setuptools.command.easy_install import main 377 410 #TGBEGIN 378 411 install_command() 379 412 #TGEND 380 return main(list(argv)+[egg]) # we're done here381 finally:382 if egg and os.path.exists(egg):383 os.unlink(egg)384 else:385 if setuptools.__version__ == '0.0.1':386 # tell the user to uninstall obsolete version387 use_setuptools(version)388 389 req = "setuptools>=" + version390 import pkg_resources391 try:392 pkg_resources.require(req)393 394 except pkg_resources.VersionConflict:395 try:396 from setuptools.command.easy_install import main397 413 except ImportError: 398 414 from easy_install import main 399 #TGBEGIN400 install_command()401 #TGEND402 415 main(list(argv)+[download_setuptools(delay=0)]) 403 416 sys.exit(0) # try to force an exit 404 417 else: 405 from setuptools.command.easy_install import main 406 #TGBEGIN 407 install_command() 408 #TGEND 409 main(argv) 410 418 if argv: 419 from setuptools.command.easy_install import main 420 #TGBEGIN 421 install_command() 422 #TGEND 423 main(argv) 424 else: 425 print "Setuptools version",version,"or greater has been installed." 426 print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' 411 427 412 428 def update_md5(filenames): … … 414 430 415 431 import re 416 from md5 import md5417 432 418 433 for name in filenames: … … 440 455 f.close() 441 456 442 443 457 if __name__=='__main__': 444 458 if len(sys.argv) > 2 and sys.argv[1] == '--md5update': 445 459 update_md5(sys.argv[2:]) 446 447 460 else: 461 #TGBEGIN 448 462 tg_main() 463 #TGEND branches/1.1/tools/tgsetup.py
r5754 r5755 4 4 from distutils import log 5 5 6 # this is the TG version 6 7 TGVERSION = "1.1b1" 7 8 TGDOWNLOAD = "http://www.turbogears.org/download/" … … 23 24 """ 24 25 import sys 26 # this is the default version of setuptools, not TG 25 27 DEFAULT_VERSION = "0.6c9" 26 DEFAULT_URL = "http:// cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3]28 DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] 27 29 28 30 md5_data = { … … 54 56 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', 55 57 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', 58 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', 56 59 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', 57 60 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', … … 63 66 64 67 import sys, os 68 try: from hashlib import md5 69 except ImportError: from md5 import md5 65 70 66 71 # TGBEGIN 67 72 win32 = """ 68 The recommended Python for TurboGears is Python 2.5.2. You can download69 it here:73 The recommended Python for TurboGears 1.1 is Python 2.5.2. 74 You can download it here: 70 75 71 76 http://www.python.org/ftp/python/2.5.2/python-2.5.2.msi … … 73 78 74 79 darwin = """ 75 The recommended Python for TurboGears is Python 2.5.2. You can download76 a Universal build here:80 The recommended Python for TurboGears 1.1 is Python 2.5.2. 81 You can download a Universal build here: 77 82 78 83 http://www.python.org/ftp/python/2.5.2/python-2.5.2-macosx.dmg … … 80 85 81 86 other = """ 82 The recommended Python for TurboGears is Python 2.5.2. This version of83 Python is often available in your operating system's native package 84 format (via apt-get or yum, for instance). You can also easily build 85 Python from source on Unix-like systems. Here is the source download 86 link for Python:87 The recommended Python for TurboGears 1.1 is Python 2.5.2. 88 This version of Python is often available in your operating system's 89 native package format (via apt-get or yum, for instance). 90 You can also easily build Python from source on Unix-like systems. 91 Here is the source download link for Python: 87 92 88 93 http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2 … … 120 125 121 126 def check_python(): 122 if sys.version_info < (2, 4):123 print "Python 2.4 or higher is required to run TurboGears >=1.1."127 if sys.version_info < (2, 4): 128 print "Python 2.4 or higher is required to run TurboGears 1.1." 124 129 125 130 if not get_python(): … … 163 168 print "Beginning setuptools/EasyInstall installation and TurboGears " \ 164 169 "download\n" 165 166 170 if len(sys.argv) > 1: 167 171 args = sys.argv[1:] … … 199 203 def finalize_options(self): 200 204 if self.future: 205 #self.args.append("TurboGears[future,testtools] >= %s" % TGVERSION) 201 206 self.args.append("TurboGears[future] == %s" % TGVERSION) 202 207 else: 203 208 self.args.append("TurboGears == %s" % TGVERSION) 204 205 209 if self.upgrade is None: 206 210 self.upgrade = True … … 238 242 def _validate_md5(egg_name, data): 239 243 if egg_name in md5_data: 240 from md5 import md5241 244 digest = md5(data).hexdigest() 242 245 if digest != md5_data[egg_name]: 243 246 print >>sys.stderr, ( 244 "md5 validation of %s failed! (Possible download problem?)"247 "md5 validation of %s failed! (Possible download problem?)" 245 248 % egg_name 246 249 ) 247 250 sys.exit(2) 248 251 return data 249 250 252 251 253 def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, … … 262 264 an attempt to abort the calling script. 263 265 """ 264 try: 265 import setuptools 266 if setuptools.__version__ == '0.0.1': 267 print >>sys.stderr, ( 268 "You have an obsolete version of setuptools installed. Please\n" 269 "remove it from your system entirely before rerunning this script." 270 ) 271 sys.exit(2) 272 except ImportError: 266 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules 267 def do_download(): 273 268 egg = download_setuptools(version, download_base, to_dir, download_delay) 274 269 sys.path.insert(0, egg) 275 270 import setuptools; setuptools.bootstrap_install_from = egg 276 277 import pkg_resources278 271 try: 279 pkg_resources.require("setuptools>="+version) 280 272 import pkg_resources 273 except ImportError: 274 return do_download() 275 try: 276 pkg_resources.require("setuptools>="+version); return 281 277 except pkg_resources.VersionConflict, e: 282 # XXX could we install in a subprocess here?283 print >>sys.stderr, (278 if was_imported: 279 print >>sys.stderr, ( 284 280 "The required version of setuptools (>=%s) is not available, and\n" 285 281 "can't be installed while this script is running. Please install\n" 286 " a more recent version first.\n\n(Currently using %r)" 287 ) % (version, e.args[0]) 288 sys.exit(2) 289 290 def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, 291 to_dir=os.curdir, delay = 15): 282 " a more recent version first, using 'easy_install -U setuptools'." 283 "\n\n(Currently using %r)" 284 ) % (version, e.args[0]) 285 sys.exit(2) 286 else: 287 del pkg_resources, sys.modules['pkg_resources'] # reload ok 288 return do_download() 289 except pkg_resources.DistributionNotFound: 290 return do_download() 291 292 def download_setuptools( 293 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, 294 delay = 15 295 ): 292 296 """Download setuptools from a specified location and return its filename 293 297 … … 335 339 def main(argv, version=DEFAULT_VERSION): 336 340 """Install or upgrade setuptools and EasyInstall""" 337 341 #TGBEGIN 338 342 try: 339 import setuptools340 341 except ImportError:342 egg = None343 343 try: 344 egg = download_setuptools(version, delay=0) 345 sys.path.insert(0,egg) 344 import setuptools 345 except ImportError: 346 egg = None 347 try: 348 egg = download_setuptools(version, delay=0) 349 sys.path.insert(0,egg) 350 from setuptools.command.easy_install import main 351 return main(list(argv)+[egg]) # we're done here 352 finally: 353 if egg and os.path.exists(egg): 354 os.unlink(egg) 355 except Exception, e: 356 print >>sys.stderr, ( 357 "Could not download and install setupools:\n%s\n" 358 "Please try installing setuptools manually." 359 % (str(e) or e.__class__.__name__)) 360 sys.exit(2) 361 if setuptools.__version__ == '0.0.1': 362 print >>sys.stderr, ( 363 "You have an obsolete version of setuptools installed. Please\n" 364 "remove it from your system entirely before rerunning this script." 365 ) 366 sys.exit(2) 367 #TGEND 368 369 req = "setuptools>=" + version 370 import pkg_resources 371 try: 372 pkg_resources.require(req) 373 except pkg_resources.VersionConflict: 374 try: 346 375 from setuptools.command.easy_install import main 347 376 #TGBEGIN 348 377 install_command() 349 378 #TGEND 350 return main(list(argv)+[egg]) # we're done here351 finally:352 if egg and os.path.exists(egg):353 os.unlink(egg)354 else:355 if setuptools.__version__ == '0.0.1':356 # tell the user to uninstall obsolete version357 use_setuptools(version)358 359 req = "setuptools>=" + version360 import pkg_resources361 try:362 pkg_resources.require(req)363 364 except pkg_resources.VersionConflict:365 try:366 from setuptools.command.easy_install import main367 379 except ImportError: 368 380 from easy_install import main 369 #TGBEGIN370 install_command()371 #TGEND372 381 main(list(argv)+[download_setuptools(delay=0)]) 373 382 sys.exit(0) # try to force an exit 374 383 else: 375 from setuptools.command.easy_install import main 376 #TGBEGIN 377 install_command() 378 #TGEND 379 main(argv) 380 384 if argv: 385 from setuptools.command.easy_install import main 386 #TGBEGIN 387 install_command() 388 #TGEND 389 main(argv) 390 else: 391 print "Setuptools version",version,"or greater has been installed." 392 print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' 381 393 382 394 def update_md5(filenames): … … 384 396 385 397 import re 386 from md5 import md5387 398 388 399 for name in filenames: … … 410 421 f.close() 411 422 412 413 423 if __name__=='__main__': 414 424 if len(sys.argv) > 2 and sys.argv[1] == '--md5update': 415 425 update_md5(sys.argv[2:]) 416 417 426 else: 427 #TGBEGIN 418 428 tg_main() 429 #TGEND branches/1.5/tools/tgsetup.py
r5482 r5755 4 4 from distutils import log 5 5 6 TGVERSION = "1.1b1" 6 # this is the TG version 7 TGVERSION = "1.5a1" 7 8 TGDOWNLOAD = "http://www.turbogears.org/download/" 8 9 … … 23 24 """ 24 25 import sys 25 DEFAULT_VERSION = "0.6c8" 26 DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] 26 # this is the default version of setuptools, not TG 27 DEFAULT_VERSION = "0.6c9" 28 DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] 27 29 28 30 md5_data = { … … 54 56 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', 55 57 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', 58 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', 56 59 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', 57 60 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', 61 'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03', 62 'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a', 63 'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6', 64 'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a', 58 65 } 59 66 60 67 import sys, os 68 try: from hashlib import md5 69 except ImportError: from md5 import md5 61 70 62 71 # TGBEGIN 63 72 win32 = """ 64 The recommended Python for TurboGears is Python 2.5.2. You can download65 it here:73 The recommended Python for TurboGears 1.5 is Python 2.5.2. 74 You can download it here: 66 75 67 76 http://www.python.org/ftp/python/2.5.2/python-2.5.2.msi … … 69 78 70 79 darwin = """ 71 The recommended Python for TurboGears is Python 2.5.2. You can download72 a Universal build here:80 The recommended Python for TurboGears 1.5 is Python 2.5.2. 81 You can download a Universal build here: 73 82 74 83 http://www.python.org/ftp/python/2.5.2/python-2.5.2-macosx.dmg … … 76 85 77 86 other = """ 78 The recommended Python for TurboGears is Python 2.5.2. This version of79 Python is often available in your operating system's native package 80 format (via apt-get or yum, for instance). You can also easily build 81 Python from source on Unix-like systems. Here is the source download 82 link for Python:87 The recommended Python for TurboGears 1.5 is Python 2.5.2. 88 This version of Python is often available in your operating system's 89 native package format (via apt-get or yum, for instance). 90 You can also easily build Python from source on Unix-like systems. 91 Here is the source download link for Python: 83 92 84 93 http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2 … … 116 125 117 126 def check_python(): 118 if sys.version_info < (2, 4):119 print "Python 2.4 or higher is required to run TurboGears >= 1.1."127 if sys.version_info < (2, 4): 128 print "Python 2.4 or higher is required to run TurboGears 1.5." 120 129 121 130 if not get_python(): … … 159 168 print "Beginning setuptools/EasyInstall installation and TurboGears " \ 160 169 "download\n" 161 162 170 if len(sys.argv) > 1: 163 171 args = sys.argv[1:] … … 195 203 def finalize_options(self): 196 204 if self.future: 205 #self.args.append("TurboGears[future,testtools] >= %s" % TGVERSION) 197 206 self.args.append("TurboGears[future] == %s" % TGVERSION) 198 207 else: 199 208 self.args.append("TurboGears == %s" % TGVERSION) 200 201 209 if self.upgrade is None: 202 210 self.upgrade = True … … 234 242 def _validate_md5(egg_name, data): 235 243 if egg_name in md5_data: 236 from md5 import md5237 244 digest = md5(data).hexdigest() 238 245 if digest != md5_data[egg_name]: 239 246 print >>sys.stderr, ( 240 "md5 validation of %s failed! (Possible download problem?)"247 "md5 validation of %s failed! (Possible download problem?)" 241 248 % egg_name 242 249 ) 243 250 sys.exit(2) 244 251 return data 245 246 252 247 253 def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, … … 258 264 an attempt to abort the calling script. 259 265 """ 260 try: 261 import setuptools 262 if setuptools.__version__ == '0.0.1': 263 print >>sys.stderr, ( 264 "You have an obsolete version of setuptools installed. Please\n" 265 "remove it from your system entirely before rerunning this script." 266 ) 267 sys.exit(2) 268 except ImportError: 266 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules 267 def do_download(): 269 268 egg = download_setuptools(version, download_base, to_dir, download_delay) 270 269 sys.path.insert(0, egg) 271 270 import setuptools; setuptools.bootstrap_install_from = egg 272 273 import pkg_resources274 271 try: 275 pkg_resources.require("setuptools>="+version) 276 272 import pkg_resources 273 except ImportError: 274 return do_download() 275 try: 276 pkg_resources.require("setuptools>="+version); return 277 277 except pkg_resources.VersionConflict, e: 278 # XXX could we install in a subprocess here?279 print >>sys.stderr, (278 if was_imported: 279 print >>sys.stderr, ( 280 280 "The required version of setuptools (>=%s) is not available, and\n" 281 281 "can't be installed while this script is running. Please install\n" 282 " a more recent version first.\n\n(Currently using %r)" 283 ) % (version, e.args[0]) 284 sys.exit(2) 285 286 def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, 287 to_dir=os.curdir, delay = 15): 282 " a more recent version first, using 'easy_install -U setuptools'." 283 "\n\n(Currently using %r)" 284 ) % (version, e.args[0]) 285 sys.exit(2) 286 else: 287 del pkg_resources, sys.modules['pkg_resources'] # reload ok 288 return do_download() 289 except pkg_resources.DistributionNotFound: 290 return do_download() 291 292 def download_setuptools( 293 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, 294 delay = 15 295 ): 288 296 """Download setuptools from a specified location and return its filename 289 297 … … 331 339 def main(argv, version=DEFAULT_VERSION): 332 340 """Install or upgrade setuptools and EasyInstall""" 333 341 #TGBEGIN 334 342 try: 335 import setuptools336 337 except ImportError:338 egg = None339 343 try: 340 egg = download_setuptools(version, delay=0) 341 sys.path.insert(0,egg) 344 import setuptools 345 except ImportError: 346 egg = None 347 try: 348 egg = download_setuptools(version, delay=0) 349 sys.path.insert(0,egg) 350 from setuptools.command.easy_install import main 351 return main(list(argv)+[egg]) # we're done here 352 finally: 353 if egg and os.path.exists(egg): 354 os.unlink(egg) 355 except Exception, e: 356 print >>sys.stderr, ( 357 "Could not download and install setupools:\n%s\n" 358 "Please try installing setuptools manually." 359 % (str(e) or e.__class__.__name__)) 360 sys.exit(2) 361 if setuptools.__version__ == '0.0.1': 362 print >>sys.stderr, ( 363 "You have an obsolete version of setuptools installed. Please\n" 364 "remove it from your system entirely before rerunning this script." 365 ) 366 sys.exit(2) 367 #TGEND 368 369 req = "setuptools>=" + version 370 import pkg_resources 371 try: 372 pkg_resources.require(req) 373 except pkg_resources.VersionConflict: 374 try: 342 375 from setuptools.command.easy_install import main 343 376 #TGBEGIN 344 377 install_command() 345 378 #TGEND 346 return main(list(argv)+[egg]) # we're done here347 finally:348 if egg and os.path.exists(egg):349 os.unlink(egg)350 else:351 if setuptools.__version__ == '0.0.1':352 # tell the user to uninstall obsolete version353 use_setuptools(version)354 355 req = "setuptools>=" + version356 import pkg_resources357 try:358 pkg_resources.require(req)359 360 except pkg_resources.VersionConflict:361 try:362 from setuptools.command.easy_install import main363 379 except ImportError: 364 380 from easy_install import main 365 #TGBEGIN366 install_command()367 #TGEND368 381 main(list(argv)+[download_setuptools(delay=0)]) 369 382 sys.exit(0) # try to force an exit 370 383 else: 371 from setuptools.command.easy_install import main 372 #TGBEGIN 373 install_command() 374 #TGEND 375 main(argv) 376 384 if argv: 385 from setuptools.command.easy_install import main 386 #TGBEGIN 387 install_command() 388 #TGEND 389 main(argv) 390 else: 391 print "Setuptools version",version,"or greater has been installed." 392 print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' 377 393 378 394 def update_md5(filenames): … … 380 396 381 397 import re 382 from md5 import md5383 398 384 399 for name in filenames: … … 406 421 f.close() 407 422 408 409 423 if __name__=='__main__': 410 424 if len(sys.argv) > 2 and sys.argv[1] == '--md5update': 411 425 update_md5(sys.argv[2:]) 412 413 426 else: 427 #TGBEGIN 414 428 tg_main() 429 #TGEND