dev.py 2.48 KB
Newer Older
1 2
##############################################################################
#
3
# Copyright (c) 2005 Zope Foundation and Contributors.
4 5 6 7 8 9 10 11 12 13
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
14 15 16 17
"""Bootstrap the buildout project itself.

This is different from a normal boostrapping process because the
buildout egg itself is installed as a develop egg.
18 19
"""

20
import os, shutil, sys, subprocess
21

Jim Fulton's avatar
Jim Fulton committed
22
for d in 'eggs', 'develop-eggs', 'bin', 'parts':
23 24 25
    if not os.path.exists(d):
        os.mkdir(d)

26 27 28
if os.path.isdir('build'):
    shutil.rmtree('build')

29 30 31 32 33 34 35 36 37
######################################################################
# Make sure we have a relatively clean environment
try:
    import pkg_resources, setuptools
except ImportError:
    pass
else:
    raise SystemError(
        "Buildout development with a pre-installed setuptools or "
38
        "distribute is not supported.")
Jim Fulton's avatar
Jim Fulton committed
39 40 41 42

######################################################################
# Install distribute
ez = {}
43 44 45 46 47 48 49

try:
    from urllib.request import urlopen
except ImportError:
    from urllib2 import urlopen

exec(urlopen('http://python-distribute.org/distribute_setup.py').read(), ez)
Jim Fulton's avatar
Jim Fulton committed
50 51 52 53 54 55 56
ez['use_setuptools'](to_dir='eggs', download_delay=0)

import pkg_resources

######################################################################
# Install buildout
if subprocess.call(
57 58
    [sys.executable] +
    ['setup.py', '-q', 'develop', '-m', '-x', '-d', 'develop-eggs'],
59
    env=dict(os.environ, PYTHONPATH=os.path.dirname(pkg_resources.__file__))):
Jim Fulton's avatar
Jim Fulton committed
60
    raise RuntimeError("buildout build failed.")
61

62
pkg_resources.working_set.add_entry('src')
63

64 65 66
import zc.buildout.easy_install
zc.buildout.easy_install.scripts(
    ['zc.buildout'], pkg_resources.working_set , sys.executable, 'bin')
67 68

bin_buildout = os.path.join('bin', 'buildout')
69

Jim Fulton's avatar
Jim Fulton committed
70
if sys.platform.startswith('java'):
71 72
    # Jython needs the script to be called twice via sys.executable
    assert subprocess.Popen([sys.executable] + [bin_buildout]).wait() == 0
73

Jim Fulton's avatar
Jim Fulton committed
74 75
if sys.version_info < (2, 6):
    bin_buildout = [bin_buildout, '-c2.4.cfg']
76
sys.exit(subprocess.Popen(bin_buildout).wait())