bootstrap.py
author primal primal007@gmail.com
Mon, 30 Jan 2012 15:19:23 +0530
branch2011
changeset 522 01b130ea8d8d
parent 1 fda1c66b25f9
permissions -rw-r--r--
Merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
##############################################################################
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Copyright (c) 2006 Zope Corporation and Contributors.
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
# All Rights Reserved.
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
#
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
# This software is subject to the provisions of the Zope Public License,
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
# FOR A PARTICULAR PURPOSE.
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
#
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
##############################################################################
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
"""Bootstrap a buildout-based project
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
Simply run this script in a directory containing a buildout.cfg.
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
The script accepts buildout command-line options, so you can
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
use the -c option to specify an alternate configuration file.
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
$Id$
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
"""
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
import os, shutil, sys, tempfile, urllib2
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
tmpeggs = tempfile.mkdtemp()
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
is_jython = sys.platform.startswith('java')
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
try:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
    import pkg_resources
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
except ImportError:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
    ez = {}
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
                         ).read() in ez
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
    import pkg_resources
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
if sys.platform == 'win32':
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
    def quote(c):
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
        if ' ' in c:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
            return '"%s"' % c # work around spawn lamosity on windows
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    43
        else:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
            return c
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
else:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    46
    def quote (c):
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    47
        return c
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    48
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    49
cmd = 'from setuptools.command.easy_install import main; main()'
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    50
ws  = pkg_resources.working_set
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
if is_jython:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    53
    import subprocess
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
    
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    55
    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', 
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    56
           quote(tmpeggs), 'zc.buildout'], 
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    57
           env=dict(os.environ,
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    58
               PYTHONPATH=
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    59
               ws.find(pkg_resources.Requirement.parse('setuptools')).location
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    60
               ),
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    61
           ).wait() == 0
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    62
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    63
else:
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    64
    assert os.spawnle(
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    65
        os.P_WAIT, sys.executable, quote (sys.executable),
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    66
        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    67
        dict(os.environ,
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    68
            PYTHONPATH=
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    69
            ws.find(pkg_resources.Requirement.parse('setuptools')).location
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    70
            ),
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    71
        ) == 0
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    72
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    73
ws.add_entry(tmpeggs)
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    74
ws.require('zc.buildout')
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    75
import zc.buildout.buildout
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    76
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
fda1c66b25f9 Added all the files from kiwipycon and the changes made for SciPy.in.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    77
shutil.rmtree(tmpeggs)