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

Fred L. Drake, Jr. fred@zope.com
Tue, 18 Mar 2003 16:27:50 -0500


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

Added Files:
	Makefile.in configure.py file_from_infile.py install.py 
	setup.py versions.py 
Log Message:
Merge new scripts and configuration/installation support from the
new-install-branch.


=== Zope/inst/Makefile.in 1.1 => 1.2 ===
--- /dev/null	Tue Mar 18 16:27:50 2003
+++ Zope/inst/Makefile.in	Tue Mar 18 16:27:49 2003
@@ -0,0 +1,73 @@
+# 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}
+
+PYTHON="<<PYTHON>>"
+TARGET_DIR=<<TARGET_DIR>>
+BUILD_DIR=<<BUILD_DIR>>
+RM=rm -f
+RMRF=rm -rf
+FIND=find
+XARGS=xargs
+CD=cd
+LN=ln -sf
+CP=cp
+INSTALL_COPY=${PYTHON} inst/install.py
+WRITE_INFILE=${PYTHON} inst/file_from_infile.py
+
+.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/setup.py <<DISTUTILS_OPTS>> build_ext -i
+
+install: build
+	${PYTHON} inst/setup.py <<DISTUTILS_OPTS>> install \
+	   --home="${TARGET_DIR}" <<OPT_FLAGS>>
+	@echo
+	@echo Zope binaries installed successfully.
+	@echo Now run \'${TARGET_DIR}/bin/mkzopeinstance\'
+
+instance: build
+	${PYTHON} bin/mkzopeinstance .
+
+# 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} bin/mkzopeinstance --user=admin:admin .
+
+# remove the instance files made with testinst (w/ prejudice)
+untestinst:
+	${RM} bin/zopectl.py
+	${RM} bin/ntservice.py
+	${RMRF} etc
+	${RMRF} log
+
+uninstall:
+	${RMRF} "${TARGET_DIR}"
+
+TESTOPTS=-v1 -d lib/python
+
+test: build
+	${PYTHON} utilities/testrunner.py ${TESTOPTS}
+
+clean:
+	${RMRF} build lib/python/build
+	${FIND} . -name '*.py[co]' -o -name 'core*' | ${XARGS} ${RM}
+
+clobber: clean untestinst
+	${FIND} lib/python -name '*.so' | ${XARGS} ${RM}


=== Zope/inst/configure.py 1.1 => 1.2 ===
--- /dev/null	Tue Mar 18 16:27:50 2003
+++ Zope/inst/configure.py	Tue Mar 18 16:27:49 2003
@@ -0,0 +1,178 @@
+##############################################################################
+#
+# 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
+import os
+import sys
+
+import versions
+
+if sys.platform == 'win32':
+    TARGET_DIR = 'c:\\Zope-' + versions.ZOPE_MAJOR_VERSION
+    IN_MAKEFILE = 'Makefile.win.in'
+    MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake build"'
+else:
+    TARGET_DIR = '/opt/Zope-' + 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.dirname(os.path.dirname(sys.argv[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(1)
+    except:
+        print 'An error occurred while trying to import zlib!'
+        import traceback; traceback.print_exc()
+        sys.exit(1)
+
+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(1)
+
+if __name__ == '__main__':
+    main()


=== Zope/inst/file_from_infile.py 1.1 => 1.2 ===
--- /dev/null	Tue Mar 18 16:27:50 2003
+++ Zope/inst/file_from_infile.py	Tue Mar 18 16:27:49 2003
@@ -0,0 +1,90 @@
+##############################################################################
+#
+# 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)
+


=== Zope/inst/install.py 1.1 => 1.2 ===
--- /dev/null	Tue Mar 18 16:27:50 2003
+++ Zope/inst/install.py	Tue Mar 18 16:27:49 2003
@@ -0,0 +1,167 @@
+##############################################################################
+#
+# 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
+#
+##############################################################################
+"""
+Generic file and directory installer.
+
+Typically called when installing Zope via the Makefile written by
+'configure.py' in the 'make install' step.
+"""
+import getopt
+import os
+import re
+import shutil
+import stat
+import sys
+
+# RE that, if a pathname's base name matches, causes it to be ignored
+# when copying that file or directory.
+default_omitpattern = r'(\..*|CVS|.*~)$'
+
+def main(src, dst, dirmode=0755, fmode=0644,
+         omitpattern=default_omitpattern, retain_xbit=1):
+    """
+    Copy a file or directory named by src to a file or directory named by
+    dst, normalizing mode bit settings as necessary.  Recursively copies
+    directory trees using shutil.copy2().
+
+    Errors are reported to standard output.
+
+      - 'dirmode' is the directory creation mode.  All directories
+        are created with this mode.
+      - 'fmode' is the default file creation mode.  This mode
+        is modified by the status of the source file.  If the source
+        file is executable, mod the fmode to be +wgo executable.
+      - omitpattern is a Python-style regex pattern.  If a file
+        or directory name matches this pattern, it will never be copied.
+      - if the dst directory already exists, don't raise an error.
+    """
+    try:
+        if os.path.isdir(src):
+            copydir(src, dst, dirmode, fmode, omitpattern,
+                    retain_xbit)
+        else:
+            names = omit([src], omitpattern)
+            names and copyfile(names[0], dst, fmode, retain_xbit)
+
+    except (IOError, os.error), why:
+        print "Can't copy %s to %s: %s" % (`src`, `dst`, str(why))
+
+def copydir(src, dst, dirmode, fmode, omitpattern, retain_xbit):
+    names = omit(os.listdir(src), omitpattern)
+    try:
+        # always create directories with dirmode
+        os.makedirs(dst, dirmode)
+    except os.error, why:
+        if why[0] == 17:
+            # directory already exists
+            pass
+        else:
+            raise
+    for name in omit(names, omitpattern):
+        srcname = os.path.join(src, name)
+        dstname = os.path.join(dst, name)
+        if os.path.isdir(srcname):
+            copydir(srcname, dstname, dirmode,fmode,omitpattern,
+                    retain_xbit)
+        else:
+            copyfile(srcname, dstname, fmode, retain_xbit)
+
+def copylink(src, dst):
+    linkto = os.readlink(src)
+    os.symlink(linkto, dst)
+
+def copyfile(src, dst, mode, retain_xbit):
+    shutil.copy2(src, dst)
+    # change dest file mode to fmode but
+    # make +wgo executable if source file is executable
+    dstmode = mode
+    st = os.stat(src)
+    srcmode = st[stat.ST_MODE]
+    if retain_xbit and (srcmode & stat.S_IEXEC):
+        dstmode = (mode | 0111)
+    if os.path.isdir(dst):
+        # if dst is a directory, copy the file in to it
+        os.chmod(os.path.join(dst, os.path.split(src)[-1]), dstmode)
+    else:
+        os.chmod(dst, dstmode)
+
+omitcache = {}
+
+def omit(names, omitpattern):
+    return [ n for n in names
+             if not re.match(omitpattern, os.path.basename(n)) ]
+
+def usage():
+    print "%s [opts] source dest" % sys.argv[0]
+    print
+    print "Copies a file or directory specified by 'source' to 'dest'"
+    print "normalizing mode bit settings as necessary."
+    print
+    print "If src is a file and dst is a directory, the file will be"
+    print "copied into the dst directory.  However, if src is a directory"
+    print "and dst is a directory, the contents of src will be copied into"
+    print "dst."
+    print
+    print "opts: --dirmode=mode --fmode=mode --omitpattern=patt"
+    print
+    print "  --dontcopyxbit   when copying a file marked as executable,"
+    print "                   don't make the copy executable."
+    print "  --dirmode        mode bit settings of dest dirs (e.g. '755')"
+    print "  --fmode          mode bit settings of dest files (e.g. '644')"
+    print "                   (modified wgo+x when dontcopyxbit is not"
+    print "                   specified)"
+    print "  --omitpattern    a Python-style regex pattern.  File and"
+    print "                   directory names which match this pattern will "
+    print "                   not be copied.  The default omitpattern is"
+    print "                   '%s'" % default_omitpattern
+
+if __name__ == '__main__':
+    if len(sys.argv) < 3:
+        print "too few arguments"
+        usage()
+        sys.exit(2)
+    dirmode = 0755
+    fmode   = 0644
+    omitpattern = default_omitpattern
+    retain_xbit = 1
+    longopts = ['dirmode=', 'fmode=', 'omitpattern=', 'help',
+                'copyxmode' ]
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'h', longopts)
+    except getopt.GetoptError, v:
+        print v
+        usage()
+        sys.exit(2)
+    try:
+        source, dest = args
+    except:
+        print "wrong number of arguments"
+        usage()
+        sys.exit(2)
+    for o, a in opts:
+        if o in ('-h', '--help'):
+            usage()
+            sys.exit()
+        if o == '--dirmode':
+            if not a.startswith('0'):
+                a = '0%s' % a
+            dirmode = eval(a)
+        if o == '--fmode':
+            if not a.startswith('0'):
+                a = '0%s' % a
+            fmode = eval(a)
+        if o == '--omitpattern':
+            omitpattern = a
+        if o == '--dontcopyxbit':
+            retain_xbit = 0
+    main(source, dest, dirmode, fmode, omitpattern, retain_xbit)


=== Zope/inst/setup.py 1.1 => 1.2 === (946/1046 lines abridged)
--- /dev/null	Tue Mar 18 16:27:50 2003
+++ Zope/inst/setup.py	Tue Mar 18 16:27:49 2003
@@ -0,0 +1,1043 @@
+#! /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 glob
+import os
+import sys
+
+import distutils.core

[-=- -=- -=- 946 lines omitted -=- -=- -=-]

+    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.core.setup(
+    name='Zope',
+    author=AUTHOR,
+
+    py_modules=setup_info.get('py_modules', []),
+    scripts=setup_info.get('scripts', []),
+    distclass=ZopeDistribution,
+    )
+
+# 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:
+        if os.path.isfile(os.path.join(dirname, name)):
+            L.append("%s/%s" % (dirname, name))
+    skel.append(("../../" + dirname, L))
+
+installed_data_files = [
+    ["../../doc", ['doc/*.txt']],
+    ["../../doc/changenotes", ['doc/changenotes/*.stx']],
+    ["../../import", ['import/*.zexp']],
+    # These may change in the future:
+    ["../../utilities", ['utilities/README.txt',
+                         'utilities/check_catalog.py',
+                         'utilities/load_site.py',
+                         'utilities/requestprofiler.py']],
+    ]
+os.path.walk("skel", skel_visit, installed_data_files)
+
+distutils.core.setup(
+    name='Zope',
+    author=AUTHOR,
+
+    data_files=installed_data_files,
+    scripts=["bin/runzope.py", "bin/zopectl.py",
+             "bin/mkzeoinstance", "bin/mkzopeinstance"],
+    distclass=ZopeDistribution,
+    )


=== Zope/inst/versions.py 1.1 => 1.2 ===
--- /dev/null	Tue Mar 18 16:27:50 2003
+++ Zope/inst/versions.py	Tue Mar 18 16:27:49 2003
@@ -0,0 +1,7 @@
+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'