[Zope-Checkins] CVS: Zope/inst - Makefile.in:1.1.4.1 configure.py:1.1.4.1 file_from_infile.py:1.1.4.1 setup.py:1.1.4.1 versions.py:1.1.4.1

Fred L. Drake, Jr. fred@zope.com
Thu, 13 Feb 2003 18:13:49 -0500


Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv14984

Added Files:
      Tag: new-install-branch
	Makefile.in configure.py file_from_infile.py setup.py 
	versions.py 
Log Message:
More installation support from the chrism-install-branch, with limited
updates.


=== Added File Zope/inst/Makefile.in ===
# Zope2 build and install Makefile.

# We do as much as possible in Python in order to avoid needing to
# learn autoconf or some other awful thing. ;-)

NAME=Zope
MAJOR_VERSION=<<ZOPE_MAJOR_VERSION>>
MINOR_VERSION=<<ZOPE_MINOR_VERSION>>
RELEASE_TAG=<<VERSION_RELEASE_TAG>>
PACKAGE_NAME=${NAME}-${MAJOR_VERSION}.${MINOR_VERSION}-${RELEASE_TAG}

# change this to your RPM source dir as necessary
RPM_SRC_DIR=${HOME}/software/rpms/Zope

PYTHON=<<PYTHON>>
TARGET_DIR=<<TARGET_DIR>>
BUILD_DIR=<<BUILD_DIR>>
OPT_FLAGS=<<OPT_FLAGS>>
INST_DIR=${BUILD_DIR}/inst
SKEL_DIR=${BUILD_DIR}/skel
INFILE_DIR=${INST_DIR}/in
RM=rm -f
RMRF=rm -rf
FIND=find
XARGS=xargs
CD=cd
LN=ln -sf
CP=cp
INSTALL_COPY="${PYTHON}" "${INST_DIR}/install.py" --copylinks
WRITE_INFILE="${PYTHON}" "${INST_DIR}/file_from_infile.py"
DISTUTILS_OPTS=<<DISTUTILS_OPTS>>

.PHONY : clean install uninstall instance links hacklinks untestinst testinst
.PHONY : default

default: build
	@echo
	@echo Zope built.  Next, do \'make install\' \(or \'make instance\'
	@echo to run a Zope instance directly from the build directory\).
	@echo

build:
	"${PYTHON}" "${INST_DIR}/setup.py" ${DISTUTILS_OPTS} build_ext -i

install: build
	${INSTALL_COPY} "${SKEL_DIR}" "${TARGET_DIR}"
	${WRITE_INFILE} "${INFILE_DIR}/mkzopeinst.py.in" \
           "${TARGET_DIR}/inst/mkzopeinst.py"
	"${PYTHON}" inst/setup.py ${DISTUTILS_OPTS} install \
	   --home="${TARGET_DIR}" ${OPT_FLAGS}
	@echo
	@echo Zope binaries installed successfully.
	@echo Now run \'${TARGET_DIR}/inst/mkzopeinst.py\'

instance: build
	"${PYTHON}" "${SKEL_DIR}/inst/mkzopeinst.py" \
          --zopehome="${BUILD_DIR}"

# testinst makes an instance home in the build directory without asking
# any questions.  this is useful when testing.  instances made with
# this can be removed via "make untestinst"
testinst: build
	"${PYTHON}" "${SKEL_DIR}/inst/mkzopeinst.py" \
          --zopehome="${BUILD_DIR}" --insthome="${BUILD_DIR}" \
          --inituser=

# remove the instance files made with testinst (w/ prejudice)
untestinst:
	${RMRF} "${BUILD_DIR}/bin/zopectl.py"
	${RMRF} "${BUILD_DIR}/bin/ntservice.py"
	${RMRF} "${BUILD_DIR}/etc"
	${RMRF} "${BUILD_DIR}/Products"

rpmdist: clean
	${RM} "${RPM_SRC_DIR}/${PACKAGE_NAME}"
	${RM} "${RPM_SRC_DIR}/${PACKAGE_NAME}.spec"
	${LN} "${BUILD_DIR}" "${RPM_SRC_DIR}/${PACKAGE_NAME}"
	cd "${RPM_SRC_DIR}" && tar cvzfh ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}
	${WRITE_INFILE} "${INST_DIR}/Zope.spec.in" \
              "${RPM_SRC_DIR}/${PACKAGE_NAME}.spec"
	cd ${RPM_SRC_DIR} && rpm -ba ${PACKAGE_NAME}.spec

uninstall:
	${RMRF} "${TARGET_DIR}"

TESTOPTS=-av1

test: build
	${CD} "${BUILD_DIR}/lib/python" && ${PYTHON} \
           ../../utilities/testrunner.py ${TESTOPTS}

clean:
	${RM} "${BUILD_DIR}/build"
	${FIND} "${BUILD_DIR}" -name '*.so' -o -name \
          '*.py[co]' -o -name 'core*' | ${XARGS} rm -f

clobber: clean
	${RMRF} bin/ etc/
	${RM} start stop inituser


=== Added File Zope/inst/configure.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
#
##############################################################################
"""
Create a Makefile for building and installing Zope.
"""
import getopt, sys, os
import versions

if sys.platform == 'win32':
    TARGET_DIR = 'c:\\Zope'
    IN_MAKEFILE = 'Makefile.win.in'
    MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake build"'
else:
    TARGET_DIR = '/opt/Zope-%s' % versions.ZOPE_MAJOR_VERSION
    IN_MAKEFILE = 'Makefile.in'
    MAKE_COMMAND='make'
    
def main():
    # below assumes this script is in the BUILD_DIR/inst directory
    BUILD_DIR=os.path.abspath(os.path.split(os.path.dirname(sys.argv[0]))[0])
    PYTHON=sys.executable
    MAKEFILE=open(os.path.join(BUILD_DIR, 'inst', IN_MAKEFILE)).read()
    REQUIRE_LF_ENABLED = 1
    REQUIRE_ZLIB=1
    OPT_FLAGS = ''
    zope_home = TARGET_DIR
    build_dir = BUILD_DIR
    python = PYTHON
    try:
        longopts = ["help", "ignore-largefile", "ignore-zlib", "prefix=",
                    "optimize"]
        opts, args = getopt.getopt(sys.argv[1:], "h", longopts)
    except getopt.GetoptError, v:
        print v
        usage()
        sys.exit(1)
    for o, a in opts:
        if o in ('-h', '--help'):
            usage()
            sys.exit()
        if o == '--prefix':
            zope_home=os.path.abspath(os.path.expanduser(a))
        if o == "--ignore-largefile":
            REQUIRE_LF_ENABLED=0
        if o == "--ignore-zlib":
            REQUIRE_ZLIB=0
        if o == "--optimize":
            OPT_FLAGS = '--optimize=1 --no-compile'
    if REQUIRE_LF_ENABLED:
        test_largefile()
    if REQUIRE_ZLIB:
        test_zlib()
    print "  - Zope top-level binary directory will be %s." % zope_home
    if OPT_FLAGS:
        print "  - Distutils install flags will be '%s'" % OPT_FLAGS
    distutils_opts = ""
    if sys.version[:3] < "2.3":
        distutils_opts = "-q"
    idata = {
        '<<PYTHON>>':python,
        '<<TARGET_DIR>>':zope_home,
        '<<BUILD_DIR>>':build_dir,
        '<<OPT_FLAGS>>':OPT_FLAGS,
        '<<ZOPE_MAJOR_VERSION>>':versions.ZOPE_MAJOR_VERSION,
        '<<ZOPE_MINOR_VERSION>>':versions.ZOPE_MINOR_VERSION,
        '<<VERSION_RELEASE_TAG>>':versions.VERSION_RELEASE_TAG,
        '<<DISTUTILS_OPTS>>':distutils_opts,
        }
    for k,v in idata.items():
        MAKEFILE = MAKEFILE.replace(k, v)
    f = open(os.path.join(BUILD_DIR, 'Makefile'), 'w')
    f.write(MAKEFILE)
    print "  - Makefile written."
    print
    print "  Next, run %s." % MAKE_COMMAND
    print

def usage():
    usage = ("""
%(program)s configures and writes a Makefile for Zope.

Defaults for options are specified in brackets.

Configuration:

  -h, --help                    display this help and exit

Options:

  --ignore-zlib                 allow configuration to proceeed if
                                Python zlib module is not found.

  --ignore-largefile            allow configuration to proceed without
                                Python large file support.

  --optimize                    compile Python files as .pyo files
                                instead of as .pyc files

Installation directories:

  --prefix=DIR                  install Zope files in DIR [%(zope_home)s]

By default, 'make install' will install Zope software files in
'%(target_dir)s'  You can specify an alternate location for these
files by using '--prefix', for example: '--prefix=$HOME/zope'.
""" % ({'program':sys.argv[0], 'target_dir':TARGET_DIR})
             )
    print usage

def test_zlib():
    try:
        import zlib
    except ImportError:
        print (
            """
The Python interpreter you are using does not appear to have the 'zlib'
library module installed.  For Zope to be able to run, you must install a
Python interpreter which includes the zlib module, or install the zlib library
into your Python interpreter manually.  The file which represents the library
is named 'zlib.so' (UNIX) or 'zlib.dll' (Windows) and is typically located in
the 'lib-dynload' directory of your Python's library directory.  Some
Python packagers ship the zlib module as a separate installable binary. If you
are using a system-provided Python installation, you may want to look for
a 'python-zlib' package (or something like it) and install it to make the
Python zlib module available to Zope.

Run the configure script with the --ignore-zlib option to prevent this
warning with the understanding that Zope will not start properly until
you've installed the zlib module.
"""
            )
        sys.exit(127)
    except:
        print 'An error occurred while trying to import zlib!'
        import traceback; traceback.print_exc()
        sys.exit(127)
        
def test_largefile():
    OK=0
    f = open(sys.argv[0], 'r')
    try:
        # 2**31 == 2147483648
        f.seek(2147483649L)
        f.close()
        OK=1
    except (IOError, OverflowError):
        f.close()
    if OK:
        return
    print (
        """
This Python interpreter does not have 'large file support' enabled. Large
file support is required to allow the default Zope ZODB database to grow
larger than 2GB on most platforms.  Either install a Python interpreter with
large file support (see
http://www.python.org/doc/current/lib/posix-large-files.html) or run this
program again with the --ignore-largefile option to prevent this warning,
with the understanding that your Zope may fail if the ZODB database
size ever exceeds 2GB.
"""
        )
    sys.exit(127)

if __name__ == '__main__':
    main()
    


=== Added File Zope/inst/file_from_infile.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
#
##############################################################################
"""
Reads a file named by 'src', performs textual replacements on the
file based on sed-style markup, and writes the result to the file named
by 'dst' unless 'dst' already exists.
"""
import getopt, os, sys
from os.path import abspath, split, dirname
import shutil
import versions

default_map = {
    'PYTHON'              : sys.executable,
    'BASE_DIR'            : abspath(split(dirname(sys.argv[0]))[0]),
    'ZOPE_MAJOR_VERSION'  : versions.ZOPE_MAJOR_VERSION,
    'ZOPE_MINOR_VERSION'  : versions.ZOPE_MINOR_VERSION,
    'ZOPE_BRANCH_NAME'    : versions.ZOPE_BRANCH_NAME,
    'VERSION_RELEASE_TAG' : versions.VERSION_RELEASE_TAG,
    }

def main(source, dest, map, force):
    if not force and os.path.exists(dest):
        print '%s exists, so I left it alone' % dest
    else:
        txt = open(source, 'rb').read()
        for k, v in map.items():
            txt = txt.replace('<<%s>>' % k, v)
        outfile = open(dest, 'wb')
        outfile.write(txt)
        outfile.close()
        shutil.copystat(source, dest)
        print "Wrote %s from %s" % (dest, source)

def usage():
    print "%s [opts] src dst" % sys.argv[0]
    print
    print "Reads a file named by 'src', performs textual replacements on "
    print "the file based on sed-style markup embedded in the infile, and "
    print "and writes the result to the file named by 'dst' unless 'dst'."
    print "already exists.  The generated file will have the same permissions"
    print "and other mode bit settings as the source file."
    print
    print "Options:"
    print
    print "  --force      Force replacement of dst even if it already exists."
    for name, value in default_map.items():
        print ("  --%s=value     controls text replacement, default '%s'"
               % (name, value))

if __name__ == '__main__':
    if len(sys.argv) < 3:
        usage()
        sys.exit(127)
    map = default_map.copy()
    force = 0
    try:
        longopts = ['help', 'force']
        for name in default_map.keys():
            longopts.append('%s=' % name)
        opts, args = getopt.getopt(sys.argv[1:], 'h', longopts)
    except getopt.GetoptError, v:
        print v
        usage()
        sys.exit(1)
    try:
        source, dest = args
    except:
        usage()
        sys.exit(1)
    for o, a in opts:
        if o in ('-h', '--help'):
            usage()
            sys.exit()
        if o == '--force':
            force = 1
        if o in map.keys():
            map[o] = a
    main(source, dest, map, force)



=== Added File Zope/inst/setup.py === (996/1096 lines abridged)
#! /usr/bin/env python
##############################################################################
#
# Copyright (c) 2002 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
#
##############################################################################

"""
Distutils setup for Zope

  In-place building

    This builds extension modules in-place, much like build_extensions.py
    does.  Use 'setup.py' like this::

      python setup.py build_ext -i

  Installation

    This builds extension modules, compiles python modules, and installs
    everything needed to support Zope instances in the directory of
    your choosing.  For example, to use '/usr/local/lib/zope'::

      python setup.py install \
        --home=/usr/local/lib/zope \
        --install-platlib=/usr/local/lib/zope \
        --install-purelib=/usr/local/lib/zope

    Note that with this method, all packages and scripts (including
    ZServer and z2.py) go in the same directory as Zope modules, which
    are distributed in lib/python.  You will need to set both ZOPE_HOME
    and SOFTWARE_HOME to point to your destination directory in order
    for Zope to work in this configuration.
"""

import os
import sys

from distutils.core import setup as distutils_setup
from distutils.extension import Extension

# This function collects setup information for one massive distutils
# run to be done at the end of the script.  If you're making a setup.py

[-=- -=- -=- 996 lines omitted -=- -=- -=-]

#       Extension(name='ZServer.medusa.sendfile.sendfilemodule',
#                 sources=['ZServer/medusa/sendfile/sendfilemodule.c'])]

# The rest of these modules live in the root of the source tree
os.chdir(ZOPE_ROOT)

def skel_visit(skel, dirname, names):
    if "CVS" in names:
        names.remove("CVS")
    L = []
    for name in names:
        fn = os.path.join(dirname, name)
        if os.path.isfile(fn):
            L.append(fn)
    skel.append((os.path.join("..", "..", dirname), L))

installed_data_files = [
    [os.path.join("..", "..", "import"), ['import/*.zexp']],
    ]
os.path.walk("skel", skel_visit, installed_data_files)

# "Top-level" stuff
setup(
    name="Zope Scripts",
    author=AUTHOR,
    scripts=["bin/runzope.py", "bin/mkzopeinstance"],
    data_files=installed_data_files,
    )

# And now, the root-level stuff

distutils_setup(
    name='Zope',
    author=AUTHOR,

    packages=setup_info.get('packages', []),
    data_files=setup_info.get('data_files', []),

    headers=setup_info.get('headers', []),
    ext_modules=setup_info.get('ext_modules', []),
    distclass=ZopeDistribution,
)
distutils_setup(
    name='Zope',
    author=AUTHOR,

    py_modules=setup_info.get('py_modules', []),
    scripts=setup_info.get('scripts', []),
    distclass=ZopeDistribution,
)


=== Added File Zope/inst/versions.py ===
ZOPE_MAJOR_VERSION  = '2.7'
ZOPE_MINOR_VERSION  = '0'
ZOPE_BRANCH_NAME    = '$Name$'[6:] or 'no-branch'

# always start prerelease branches with '0' to avoid upgrade
# issues in RPMs
VERSION_RELEASE_TAG = '0test'