annotate cmd2/bootstrap.py @ 110:234fb764becd

moved README
author catherine@dellzilla
date Fri, 24 Oct 2008 16:55:49 -0400
parents 3de2a3eb765a
children
rev   line source
5
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
1 ##############################################################################
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
2 #
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
3 # Copyright (c) 2006 Zope Corporation and Contributors.
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
4 # All Rights Reserved.
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
5 #
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
6 # This software is subject to the provisions of the Zope Public License,
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
7 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
8 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
9 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
10 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
11 # FOR A PARTICULAR PURPOSE.
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
12 #
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
13 ##############################################################################
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
14 """Bootstrap a buildout-based project
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
15
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
16 Simply run this script in a directory containing a buildout.cfg.
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
17 The script accepts buildout command-line options, so you can
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
18 use the -c option to specify an alternate configuration file.
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
19
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
20 $Id$
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
21 """
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
22
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
23 import os, shutil, sys, tempfile, urllib2
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
24
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
25 tmpeggs = tempfile.mkdtemp()
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
26
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
27 try:
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
28 import pkg_resources
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
29 except ImportError:
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
30 ez = {}
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
31 exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
32 ).read() in ez
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
33 ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
34
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
35 import pkg_resources
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
36
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
37 if sys.platform == 'win32':
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
38 def quote(c):
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
39 if ' ' in c:
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
40 return '"%s"' % c # work around spawn lamosity on windows
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
41 else:
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
42 return c
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
43 else:
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
44 def quote (c):
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
45 return c
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
46
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
47 cmd = 'from setuptools.command.easy_install import main; main()'
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
48 ws = pkg_resources.working_set
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
49 assert os.spawnle(
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
50 os.P_WAIT, sys.executable, quote (sys.executable),
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
51 '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
52 dict(os.environ,
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
53 PYTHONPATH=
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
54 ws.find(pkg_resources.Requirement.parse('setuptools')).location
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
55 ),
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
56 ) == 0
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
57
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
58 ws.add_entry(tmpeggs)
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
59 ws.require('zc.buildout')
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
60 import zc.buildout.buildout
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
61 zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
2d6280e022e4 first try with buildout
catherine@cordelia
parents:
diff changeset
62 shutil.rmtree(tmpeggs)