source: products/vendor/Products.MailHost/current/bootstrap.py

Last change on this file was 3356, checked in by fenix, 12 years ago

Load 2.13.1 into vendor/Products.MailHost?/current.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1##############################################################################
2#
3# Copyright (c) 2006 Zope Foundation and Contributors.
4# All Rights Reserved.
5#
6# This software is subject to the provisions of the Zope Public License,
7# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11# FOR A PARTICULAR PURPOSE.
12#
13##############################################################################
14"""Bootstrap a buildout-based project
15
16Simply run this script in a directory containing a buildout.cfg.
17The script accepts buildout command-line options, so you can
18use the -c option to specify an alternate configuration file.
19
20$Id: bootstrap.py 108946 2010-02-12 02:40:18Z yusei $
21"""
22
23import os, shutil, sys, tempfile, urllib2
24from optparse import OptionParser
25
26tmpeggs = tempfile.mkdtemp()
27
28is_jython = sys.platform.startswith('java')
29
30# parsing arguments
31parser = OptionParser()
32parser.add_option("-v", "--version", dest="version",
33                          help="use a specific zc.buildout version")
34parser.add_option("-d", "--distribute",
35                   action="store_true", dest="distribute", default=False,
36                   help="Use Distribute rather than Setuptools.")
37
38parser.add_option("-c", None, action="store", dest="config_file",
39                   help=("Specify the path to the buildout configuration "
40                         "file to be used."))
41
42options, args = parser.parse_args()
43
44# if -c was provided, we push it back into args for buildout' main function
45if options.config_file is not None:
46    args += ['-c', options.config_file]
47
48if options.version is not None:
49    VERSION = '==%s' % options.version
50else:
51    VERSION = ''
52
53USE_DISTRIBUTE = options.distribute
54args = args + ['bootstrap']
55
56to_reload = False
57try:
58    import pkg_resources
59    if not hasattr(pkg_resources, '_distribute'):
60        to_reload = True
61        raise ImportError
62except ImportError:
63    ez = {}
64    if USE_DISTRIBUTE:
65        exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
66                         ).read() in ez
67        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
68    else:
69        exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
70                             ).read() in ez
71        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
72
73    if to_reload:
74        reload(pkg_resources)
75    else:
76        import pkg_resources
77
78if sys.platform == 'win32':
79    def quote(c):
80        if ' ' in c:
81            return '"%s"' % c # work around spawn lamosity on windows
82        else:
83            return c
84else:
85    def quote (c):
86        return c
87
88cmd = 'from setuptools.command.easy_install import main; main()'
89ws  = pkg_resources.working_set
90
91if USE_DISTRIBUTE:
92    requirement = 'distribute'
93else:
94    requirement = 'setuptools'
95
96if is_jython:
97    import subprocess
98
99    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
100           quote(tmpeggs), 'zc.buildout' + VERSION],
101           env=dict(os.environ,
102               PYTHONPATH=
103               ws.find(pkg_resources.Requirement.parse(requirement)).location
104               ),
105           ).wait() == 0
106
107else:
108    assert os.spawnle(
109        os.P_WAIT, sys.executable, quote (sys.executable),
110        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
111        dict(os.environ,
112            PYTHONPATH=
113            ws.find(pkg_resources.Requirement.parse(requirement)).location
114            ),
115        ) == 0
116
117ws.add_entry(tmpeggs)
118ws.require('zc.buildout' + VERSION)
119import zc.buildout.buildout
120zc.buildout.buildout.main(args)
121shutil.rmtree(tmpeggs)
Note: See TracBrowser for help on using the repository browser.