/docs/gp.fileupload Gawel's repository

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