#!/usr/bin/env python2.4
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# 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.
#
##############################################################################
"""Script to create a new Zope instance home.

$Id$
"""

import os
import sys

here = os.path.dirname(os.path.realpath(__file__))
swhome = os.path.dirname(here)

from_checkout = os.path.isdir(os.path.join(swhome, ".svn"))

for parts in [
    ("src",), 
    ("lib", "python"), 
    ("lib64", "python"), 
    ("Lib", "site-packages"),
    ]:
    d = os.path.join(swhome, *(parts + ("zope", "app", "appsetup")))
    if os.path.isdir(d):
        d = os.path.join(swhome, *parts)
        sys.path.insert(0, d)
        break
else:
    try:
        import zope.app.server
    except ImportError:
        print >>sys.stderr, "Could not locate Zope software installation!"
        sys.exit(1)


from zope.app.server.mkzopeinstance import main


sys.exit(main(from_checkout=from_checkout))
