OLD | NEW |
1 #!python | 1 #!python |
2 | 2 |
3 # This file was obtained from: | 3 # This file was obtained from: |
4 # http://peak.telecommunity.com/dist/ez_setup.py | 4 # http://peak.telecommunity.com/dist/ez_setup.py |
5 # on 2011/1/21. | 5 # on 2011/1/21. |
6 | 6 |
7 """Bootstrap setuptools installation | 7 """Bootstrap setuptools installation |
8 | 8 |
9 If you want to use setuptools in your package's setup.py, just include this | 9 If you want to use setuptools in your package's setup.py, just include this |
10 file in the same directory with it, and add this to the top of your setup.py:: | 10 file in the same directory with it, and add this to the top of your setup.py:: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules | 100 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules |
101 def do_download(): | 101 def do_download(): |
102 egg = download_setuptools(version, download_base, to_dir, download_delay
) | 102 egg = download_setuptools(version, download_base, to_dir, download_delay
) |
103 sys.path.insert(0, egg) | 103 sys.path.insert(0, egg) |
104 import setuptools; setuptools.bootstrap_install_from = egg | 104 import setuptools; setuptools.bootstrap_install_from = egg |
105 try: | 105 try: |
106 import pkg_resources | 106 import pkg_resources |
107 except ImportError: | 107 except ImportError: |
108 return do_download() | 108 return do_download() |
109 try: | 109 try: |
110 return do_download() | |
111 pkg_resources.require("setuptools>="+version); return | 110 pkg_resources.require("setuptools>="+version); return |
112 except pkg_resources.VersionConflict, e: | 111 except pkg_resources.VersionConflict, e: |
113 if was_imported: | 112 if was_imported: |
114 print >>sys.stderr, ( | 113 print >>sys.stderr, ( |
115 "The required version of setuptools (>=%s) is not available, and\n" | 114 "The required version of setuptools (>=%s) is not available, and\n" |
116 "can't be installed while this script is running. Please install\n" | 115 "can't be installed while this script is running. Please install\n" |
117 " a more recent version first, using 'easy_install -U setuptools'." | 116 " a more recent version first, using 'easy_install -U setuptools'." |
118 "\n\n(Currently using %r)" | 117 "\n\n(Currently using %r)" |
119 ) % (version, e.args[0]) | 118 ) % (version, e.args[0]) |
120 sys.exit(2) | 119 sys.exit(2) |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 f = open(srcfile,'w') | 274 f = open(srcfile,'w') |
276 f.write(src) | 275 f.write(src) |
277 f.close() | 276 f.close() |
278 | 277 |
279 | 278 |
280 if __name__=='__main__': | 279 if __name__=='__main__': |
281 if len(sys.argv)>2 and sys.argv[1]=='--md5update': | 280 if len(sys.argv)>2 and sys.argv[1]=='--md5update': |
282 update_md5(sys.argv[2:]) | 281 update_md5(sys.argv[2:]) |
283 else: | 282 else: |
284 main(sys.argv[1:]) | 283 main(sys.argv[1:]) |
OLD | NEW |