[Zope-Checkins] CVS: Zope/utilities - zope.py:1.1.2.1 zctl_lib.py:NONE

Chris McDonough chrism@zope.com
Sun, 29 Sep 2002 17:46:27 -0400


Update of /cvs-repository/Zope/utilities
In directory cvs.zope.org:/tmp/cvs-serv12114/utilities

Added Files:
      Tag: chrism-install-branch
	zope.py 
Removed Files:
      Tag: chrism-install-branch
	zctl_lib.py 
Log Message:
Updates to the chrism-install-branch:

  - Uses distutils (setup.py) to install all software kept in the
    'lib/python' directory.  This means that the setup.py file
    (which has moved into the inst directory) will need to be maintained
    as new packages, files, and directories are added.  This is
    painful, but it's "the right thing".  It is a departure from the
    past inasmuch as (if this branch is merged into the head at some
    point) when people add stuff to the Zope tree, they will need to
    be careful to update the setup.py file as well.  I know this will become
    incredibly problematic.  To make things easier, it might be
    a reasonable thing to autogenerate a setup.py file based on the
    current state of the Zope tree.  But this is not done yet.
    BTW, many thanks to Matt Hamilton for making the incredible setup.py file
    for all Zope packages.

  - No longer copies the build directory wholesale to create a
    ZOPE_HOME.  Instead 'make install' copies a 'skeleton' directory to the 
    target dir using a custom Python installer and writes out
    files that need post-processing (.in files) to places in the
    hierarchy as needed via the Makefile.  This prevents a lot of
    cruft from reaching the target directory (build directories,
    emacs backup files, etc.)

  - Has an improved 'make instance' implementation which also uses
    a skeleton directory and a similar install.

  - Does away with much cruft in the 'inst' directory lefover from
    band-aids that were produced in the past.

Concessions were made to the realities of moving directories in CVS
for this go-around.  It is desirable to move lots of the current
"top-level" directories (import, var, utilities, Extensions, pcgi, etc.)
into the "skeleton" directory for the kind of install strategy implemented
by this branch, but this is not reasonable as we would divorce these 
packages from updates received on the head if were were to do so now.
If we merge this branch into the head, we will do away with the workarounds
and move the directories.
  


=== Added File Zope/utilities/zope.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
#
##############################################################################
"""
This is a replacement for z2.py which uses a config file.

Do not change this file unless you know what you're doing. ;-)
"""

import os, sys, getopt, warnings, traceback

# assume that this file is sys.argv[0], and that it lives in ZOPE_HOME
# or ZOPE_HOME/bin in order to set get the default SOFTWARE_HOME appropriately
# so we can get at the Controller package.

HERE = os.path.split(os.path.abspath(os.path.normpath(sys.argv[0])))[0]
if os.path.split(HERE)[1] == 'bin':
    # zope.py is probably in a 'bin' directory in the ZOPE_HOME
    SOFTWARE_HOME = os.path.join(os.path.split(HERE)[0], 'lib', 'python')
else:
    # zope.py is probably in the root directory of the ZOPE_HOME
    SOFTWARE_HOME = os.path.join(HERE, 'lib', 'python')

def check_python_version():
    # check for Python version
    python_version = sys.version.split()[0]
    if python_version < '2.1':
        raise 'Invalid python version', python_version
    if python_version[:3] == '2.1':
        if python_version[4:5] < '3':
            err = ('You are running Python version %s.  This Python version '
                   'has known bugs that may cause Zope to run improperly. '
                   'Consider upgrading to a Python in the 2.1 series '
                   'with at least version number 2.1.3.  (Note that Zope does '
                   'not yet run under any Python 2.2 version).' %
                   python_version)
            warnings.warn(err)
    if python_version[:3] == '2.2':
        err = ('You are running Python version %s.  This Python version '
               'has not yet been tested with Zope and you may experience '
               'operational problems as a result.  Consider using '
               'Python 2.1.3 instead.' % python_version)
        warnings.warn(err)

def usage():
    print """
zope.py [--config-location=filename-or-url] [--software_home=path]

zope.py starts a Zope instance.

If the software-home option is not passed, Zope assumes that the software
home

If the config-location option is not passed, an attempt is made to obtain
configuration info from a file in the current working directory named
'%s'.  An alternate absolute or relative filename may be
provided, or a URL may be provided.  If a URL is specified, it should begin
with 'http://'.  The url should return a file in the same format as the
filesystem config file.
""" % {'me':sys.argv[0]}

if __name__ == '__main__':
    check_python_version()
    config_location = 'zope.conf'
    url = None
    sw_home = SOFTWARE_HOME
    longopts = [ "help", "config-location="]
    try:
        opts, args = getopt.getopt(sys.argv[1:], "h", longopts)
    except getopt.GetoptError, v:
        print v
        usage()
        sys.exit(127)
    for k, v in opts:
        if k in ('-h', '--help'):
            usage()
            sys.exit(0)
        if k == '--config-location':
            config_location = v
        if k == '--software-home':
            sw_home = v
    if not os.path.exists(sw_home):
        print "software-home directory %s doesn't exist!" % sw_home
        usage()
        sys.exit(127)
    # an importer may have already set SOFTWARE_HOME
    if sw_home not in sys.path:
        sys.path.insert(0, sw_home)
    try:
        from Controller import Main
        Main.start_zope(config_location)
    except SystemExit:
        pass
    except:
        try:
            import zLOG
            zLOG.LOG("Zope Initialization", zLOG.PANIC, "Startup exception",
                     error=sys.exc_info())
        except:
            pass
        traceback.print_exc()
        # tell zdaemon not to restart us by setting 255 exit code
        sys.exit(255)

            
    
            


=== Removed File Zope/utilities/zctl_lib.py ===