[Checkins] SVN: zwiki/trunk/bootstrap.py Upgrade bootstrap.py to new one available in zc.buildout
Baiju M
baiju.m.mail at gmail.com
Sun Mar 1 01:12:58 EST 2009
Log message for revision 97390:
Upgrade bootstrap.py to new one available in zc.buildout
Changed:
U zwiki/trunk/bootstrap.py
-=-
Modified: zwiki/trunk/bootstrap.py
===================================================================
--- zwiki/trunk/bootstrap.py 2009-03-01 04:07:36 UTC (rev 97389)
+++ zwiki/trunk/bootstrap.py 2009-03-01 06:12:58 UTC (rev 97390)
@@ -24,27 +24,52 @@
tmpeggs = tempfile.mkdtemp()
-ez = {}
-exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
- ).read() in ez
-ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+is_jython = sys.platform.startswith('java')
-import pkg_resources
+try:
+ import pkg_resources
+except ImportError:
+ ez = {}
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
-cmd = 'from setuptools.command.easy_install import main; main()'
+ import pkg_resources
+
if sys.platform == 'win32':
- cmd = '"%s"' % cmd # work around spawn lamosity on windows
+ def quote(c):
+ if ' ' in c:
+ return '"%s"' % c # work around spawn lamosity on windows
+ else:
+ return c
+else:
+ def quote (c):
+ return c
-ws = pkg_resources.working_set
-assert os.spawnle(
- os.P_WAIT, sys.executable, sys.executable,
- '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
- dict(os.environ,
- PYTHONPATH=
- ws.find(pkg_resources.Requirement.parse('setuptools')).location
- ),
- ) == 0
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws = pkg_resources.working_set
+if is_jython:
+ import subprocess
+
+ assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+ quote(tmpeggs), 'zc.buildout'],
+ env=dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ).wait() == 0
+
+else:
+ assert os.spawnle(
+ os.P_WAIT, sys.executable, quote (sys.executable),
+ '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
More information about the Checkins
mailing list