[Checkins] SVN: zc.buildout/branches/py3k/ checkpoint
Fred Drake
fdrake at gmail.com
Tue Nov 3 19:22:33 EST 2009
Log message for revision 105471:
checkpoint
Changed:
U zc.buildout/branches/py3k/bootstrap/bootstrap.py
U zc.buildout/branches/py3k/dev.py
U zc.buildout/branches/py3k/src/zc/buildout/easy_install.py
-=-
Modified: zc.buildout/branches/py3k/bootstrap/bootstrap.py
===================================================================
--- zc.buildout/branches/py3k/bootstrap/bootstrap.py 2009-11-04 00:16:35 UTC (rev 105470)
+++ zc.buildout/branches/py3k/bootstrap/bootstrap.py 2009-11-04 00:22:33 UTC (rev 105471)
@@ -20,9 +20,28 @@
$Id$
"""
-import os, shutil, sys, tempfile, urllib2
+import os, shutil, sys, tempfile
from optparse import OptionParser
+try:
+ from urllib2 import urlopen
+except ImportError:
+ from urllib.request import urlopen
+
+
+def execute(source, globals=None, locals=None, filename="<string>"):
+ code = compile(source, filename, "exec")
+ if globals is None:
+ globals = {}
+ if locals is None:
+ locals = globals
+ if sys.version_info[0] == 2:
+ run = compile("exec code in globals, locals ", "<string>", "exec")
+ exec(run)
+ else:
+ exec(code, globals, locals)
+
+
tmpeggs = tempfile.mkdtemp()
is_jython = sys.platform.startswith('java')
@@ -61,15 +80,15 @@
raise ImportError
except ImportError:
ez = {}
+ opts = {"to_dir": tmpeggs, "download_delay": 0}
if USE_DISTRIBUTE:
- exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
- ).read() in ez
- ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
+ url = 'http://python-distribute.org/distribute_setup.py'
+ opts["no_fake"] = True
else:
- exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
- ).read() in ez
- ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+ url = 'http://peak.telecommunity.com/dist/ez_setup.py'
+ execute(urlopen(url).read(), ez, filename=url)
+ ez['use_setuptools'](**opts)
if to_reload:
reload(pkg_resources)
else:
Modified: zc.buildout/branches/py3k/dev.py
===================================================================
--- zc.buildout/branches/py3k/dev.py 2009-11-04 00:16:35 UTC (rev 105470)
+++ zc.buildout/branches/py3k/dev.py 2009-11-04 00:22:33 UTC (rev 105471)
@@ -19,10 +19,47 @@
$Id$
"""
-import os, shutil, sys, subprocess, urllib2
+import os, shutil, sys, subprocess
+from optparse import OptionParser
+try:
+ from urllib2 import urlopen
+except ImportError:
+ from urllib.request import urlopen
+
+
+def execute(source, globals=None, locals=None, filename="<string>"):
+ code = compile(source, filename, "exec")
+ if globals is None:
+ globals = {}
+ if locals is None:
+ locals = globals
+ if sys.version_info[0] == 2:
+ run = compile("exec code in globals, locals ", "<string>", "exec")
+ exec(run)
+ else:
+ exec(code, globals, locals)
+
+
is_jython = sys.platform.startswith('java')
+# parsing arguments
+parser = OptionParser()
+parser.add_option("-d", "--distribute",
+ action="store_true", dest="distribute", default=False,
+ help="Use Disribute rather than Setuptools.")
+
+parser.add_option("-c", None, action="store", dest="config_file",
+ help=("Specify the path to the buildout configuration "
+ "file to be used."))
+
+options, args = parser.parse_args()
+USE_DISTRIBUTE = options.distribute
+
+# if -c was provided, we push it back into args for buildout' main function
+if options.config_file is not None:
+ args += ['-c', options.config_file]
+
for d in 'eggs', 'develop-eggs', 'bin':
if not os.path.exists(d):
os.mkdir(d)
@@ -30,15 +67,27 @@
if os.path.isdir('build'):
shutil.rmtree('build')
+to_reload = False
try:
import pkg_resources
+ if not hasattr(pkg_resources, '_distribute'):
+ to_reload = True
+ raise ImportError
except ImportError:
ez = {}
- exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
- ).read() in ez
- ez['use_setuptools'](to_dir='eggs', download_delay=0)
+ opts = {"to_dir": "eggs", "download_delay": 0}
+ if USE_DISTRIBUTE:
+ url = 'http://python-distribute.org/distribute_setup.py'
+ opts["no_fake"] = True
+ else:
+ url = 'http://peak.telecommunity.com/dist/ez_setup.py'
- import pkg_resources
+ execute(urlopen(url).read(), ez, filename=url)
+ ez['use_setuptools'](**opts)
+ if to_reload:
+ reload(pkg_resources)
+ else:
+ import pkg_resources
subprocess.Popen(
[sys.executable] +
Modified: zc.buildout/branches/py3k/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/py3k/src/zc/buildout/easy_install.py 2009-11-04 00:16:35 UTC (rev 105470)
+++ zc.buildout/branches/py3k/src/zc/buildout/easy_install.py 2009-11-04 00:22:33 UTC (rev 105471)
@@ -658,8 +658,8 @@
while 1:
try:
ws.resolve(requirements)
- except pkg_resources.DistributionNotFound, err:
- [requirement] = err
+ except pkg_resources.DistributionNotFound:
+ [requirement] = sys.exc_info()[2]
requirement = self._constrain(requirement)
if dest:
logger.debug('Getting required %r', str(requirement))
@@ -672,8 +672,8 @@
ws.add(dist)
self._maybe_add_setuptools(ws, dist)
- except pkg_resources.VersionConflict, err:
- raise VersionConflict(err, ws)
+ except pkg_resources.VersionConflict:
+ raise VersionConflict(sys.exc_info()[2], ws)
else:
break
@@ -915,7 +915,7 @@
path = [dist.location for dist in working_set]
path.extend(extra_paths)
- path = map(realpath, path)
+ path = [realpath(p) for p in path]
generated = []
@@ -1056,7 +1056,7 @@
logger.info("Generated script %r.", script)
try:
- os.chmod(dest, 0755)
+ os.chmod(dest, int("0755", 8))
except (AttributeError, os.error):
pass
@@ -1108,7 +1108,7 @@
if changed:
open(dest, 'w').write(contents)
try:
- os.chmod(dest,0755)
+ os.chmod(dest, int("0755", 8))
except (AttributeError, os.error):
pass
logger.info("Generated interpreter %r.", script)
More information about the checkins
mailing list