diff options
| author | PJ Eby <distutils-sig@python.org> | 2005-06-15 02:19:42 +0000 |
|---|---|---|
| committer | PJ Eby <distutils-sig@python.org> | 2005-06-15 02:19:42 +0000 |
| commit | 5a9445cd57c60bb47451d8a88ec12a7a865013b7 (patch) | |
| tree | 75dab611dd00efff933bad3fb579dadd37ddd7ef /ez_setup.py | |
| parent | 13c8739a6b43cb59ad0dfbd7751148d427af6170 (diff) | |
| download | python-setuptools-git-5a9445cd57c60bb47451d8a88ec12a7a865013b7.tar.gz | |
Add bootstrap installation support that "hitches a ride" on other packages
being installed via the normal distutils "setup.py install". Also, don't
repeatedly download the setuptools egg if it's already in the target
location.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041069
Diffstat (limited to 'ez_setup.py')
| -rwxr-xr-x | ez_setup.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/ez_setup.py b/ez_setup.py index 887c4dcc..c59baf06 100755 --- a/ez_setup.py +++ b/ez_setup.py @@ -63,8 +63,10 @@ def use_setuptools( sys.exit(2) except ImportError: - sys.path.insert(0, download_setuptools(version, download_base, to_dir)) - + egg = download_setuptools(version, download_base, to_dir) + sys.path.insert(0, egg) + import setuptools; setuptools.bootstrap_install_from = egg + import pkg_resources try: pkg_resources.require("setuptools>="+version) @@ -78,8 +80,6 @@ def use_setuptools( ) % version sys.exit(2) - - def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir ): @@ -95,13 +95,19 @@ def download_setuptools( saveto = os.path.join(to_dir, egg_name) src = dst = None - try: - src = urllib2.urlopen(url) - dst = open(saveto,"wb") - shutil.copyfileobj(src,dst) - finally: - if src: src.close() - if dst: dst.close() + if not os.path.exists(saveto): # Avoid repeated downloads + try: + from distutils import log + log.warn("Downloading %s", url) + src = urllib2.urlopen(url) + # Read/write all in one block, so we don't create a corrupt file + # if the download is interrupted. + data = src.read() + dst = open(saveto,"wb") + dst.write(data) + finally: + if src: src.close() + if dst: dst.close() return os.path.realpath(saveto) @@ -115,12 +121,6 @@ def download_setuptools( - - - - - - def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" |
