bootstrap.py
author Sverre Rabbelier <srabbelier@gmail.com>
Sat, 12 Sep 2009 14:38:42 +0200
changeset 2905 378833eb5a95
parent 2587 ec7818110fd2
permissions -rw-r--r--
Fix copy/paste fail in maintenance middleware docstring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2587
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     1
##############################################################################
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     2
#
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     3
# Copyright (c) 2006 Zope Corporation and Contributors.
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     4
# All Rights Reserved.
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     5
#
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     6
# This software is subject to the provisions of the Zope Public License,
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    11
# FOR A PARTICULAR PURPOSE.
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    12
#
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    13
##############################################################################
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    14
"""Bootstrap a buildout-based project
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    15
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    16
Simply run this script in a directory containing a buildout.cfg.
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    17
The script accepts buildout command-line options, so you can
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    18
use the -c option to specify an alternate configuration file.
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    19
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    20
$Id: bootstrap.py 73144 2007-03-12 05:25:36Z baijum $
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    21
"""
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    22
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    23
import os, shutil, sys, tempfile, urllib2
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    24
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    25
tmpeggs = tempfile.mkdtemp()
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    26
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    27
ez = {}
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    28
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    29
                     ).read() in ez
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    30
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    31
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    32
import pkg_resources
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    33
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    34
cmd = 'from setuptools.command.easy_install import main; main()'
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    35
if sys.platform == 'win32':
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    36
    cmd = '"%s"' % cmd # work around spawn lamosity on windows
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    37
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    38
ws = pkg_resources.working_set
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    39
assert os.spawnle(
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    40
    os.P_WAIT, sys.executable, sys.executable,
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    41
    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    42
    dict(os.environ,
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    43
         PYTHONPATH=
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    44
         ws.find(pkg_resources.Requirement.parse('setuptools')).location
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    45
         ),
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    46
    ) == 0
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    47
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    48
ws.add_entry(tmpeggs)
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    49
ws.require('zc.buildout')
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    50
import zc.buildout.buildout
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    51
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
ec7818110fd2 Start using buildout to bring in external dependencies.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    52
shutil.rmtree(tmpeggs)