[Python-checkins] python/nondist/sandbox/setuptools ez_setup.py, 1.3, 1.4
pje@users.sourceforge.net
pje at users.sourceforge.net
Wed Jun 15 04:19:44 CEST 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11977
Modified Files:
ez_setup.py
Log Message:
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.
Index: ez_setup.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/ez_setup.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ez_setup.py 14 Jun 2005 15:48:44 -0000 1.3
+++ ez_setup.py 15 Jun 2005 02:19:42 -0000 1.4
@@ -63,8 +63,10 @@
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 @@
) % version
sys.exit(2)
-
-
def download_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir
):
@@ -95,13 +95,19 @@
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 main(argv, version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
More information about the Python-checkins
mailing list