Commit b4c7a375 authored by Chris McDonough's avatar Chris McDonough

Allow for Zope's 'configure' to be run from outside the source directory.

When this is done, the makefile and all temp build files are written to
the directory from which you run configure.  This is to support
Tres' desire to be able to install Zope from read-only media.

Perform minor cleanups, extensions, and refactorings of setup.py and
configure.py along the way.
parent dbcca378
#!/bin/sh
# Zope configure script
# $Id: configure,v 1.2 2003/03/18 21:27:49 fdrake Exp $
# $Revision: 1.2 $
# $Id: configure,v 1.3 2003/03/21 21:35:03 chrism Exp $
# $Revision: 1.3 $
#####################################################################
# BEGIN EDITABLE PARAMETERS #
#####################################################################
# Place the Zope major version number below.
ZOPE_VERS=2.7
# Place the optimal target version number for Zope (as returned by sys.version)
# below
TARGET="2.2.2"
......@@ -33,7 +36,7 @@ usage()
{
echo
echo "configure [--help] [--with-python=path] [--prefix=path] "
echo " [--ignore-largefile]"
echo " [--build-base=path] [--ignore-largefile] [--ignore-zlib]"
echo
echo " Creates a Makefile suitable for building and installing Zope"
echo
......@@ -41,11 +44,13 @@ usage()
echo " --help shows usage and quits"
echo " --with-python specify a path to a Python interpreter to use"
echo " --prefix specify an installation path for binary data"
echo " --build-base specify a temporary path for build files"
echo " --ignore-largefile ignore large file support warnings"
echo " --ignore-zlib ignore warnings about zlib"
echo " --quiet suppress nonessential output"
echo
echo " Given no options, configure will search your PATH for a suitable"
echo " Python interpreter and will use '/usr/local/zope' as a prefix."
echo " Python interpreter and will use '/opt/Zope-$ZOPE_VERS' as a prefix."
echo
}
......
......@@ -10,8 +10,17 @@ RELEASE_TAG=<<VERSION_RELEASE_TAG>>
PACKAGE_NAME=${NAME}-${MAJOR_VERSION}.${MINOR_VERSION}-${RELEASE_TAG}
PYTHON="<<PYTHON>>"
TARGET_DIR=<<TARGET_DIR>>
BUILD_DIR=<<BUILD_DIR>>
PREFIX=<<PREFIX>>
BASE_DIR=<<BASE_DIR>>
BUILD_BASE=<<BUILD_BASE>>
DISTUTILS_OPTS=<<DISTUTILS_OPTS>>
INSTALL_FLAGS=<<INSTALL_FLAGS>>
BUILD_SUBDIR=build
BUILD_FLAGS=--build-base="${BUILD_BASE}" \
--build-lib="${BUILD_BASE}/${BUILD_SUBDIR}" \
--build-scripts="${BUILD_BASE}/${BUILD_SUBDIR}/build_scripts.tmp" \
--build-temp="${BUILD_BASE}/${BUILD_SUBDIR}/build_temp.tmp"
RM=rm -f
RMRF=rm -rf
FIND=find
......@@ -19,10 +28,8 @@ 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 : clean install uninstall instance untestinst testinst
.PHONY : default
default: build
......@@ -32,42 +39,45 @@ default: build
@echo
build:
${PYTHON} inst/setup.py <<DISTUTILS_OPTS>> build_ext -i
${PYTHON} "${BASE_DIR}/inst/setup.py" \
${DISTUTILS_OPTS} build ${BUILD_FLAGS}
install: build
${PYTHON} inst/setup.py <<DISTUTILS_OPTS>> install \
--home="${TARGET_DIR}" <<OPT_FLAGS>>
${PYTHON} "${BASE_DIR}/inst/setup.py" ${DISTUTILS_OPTS} install \
--home="${PREFIX}" ${BUILD_FLAGS} ${INSTALL_FLAGS}
@echo
@echo Zope binaries installed successfully.
@echo Now run \'${TARGET_DIR}/bin/mkzopeinstance\'
@echo Now run \'${PREFIX}/bin/mkzopeinstance\'
instance: build
${PYTHON} bin/mkzopeinstance .
instance:
${PYTHON} "${BASE_DIR}/inst/setup.py" ${DISTUTILS_OPTS} build_ext -i
${PYTHON} "${BASE_DIR}/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 .
${PYTHON} "${BASE_DIR}/inst/setup.py" ${DISTUTILS_OPTS} build_ext -i
${PYTHON} "${BASE_DIR}/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
${RM} "${BASE_DIR}/bin/zopectl.py"
${RM} "${BASE_DIR}/bin/ntservice.py"
${RMRF} "${BASE_DIR}/etc"
${RMRF} "${BASE_DIR}/log"
uninstall:
${RMRF} "${TARGET_DIR}"
${RMRF} "${PREFIX}"
TESTOPTS=-v1 -d lib/python
test: build
${PYTHON} utilities/testrunner.py ${TESTOPTS}
${PYTHON} "${BASE_DIR}/utilities/testrunner.py" ${TESTOPTS}
clean:
${RMRF} build lib/python/build
${FIND} . -name '*.py[co]' -o -name 'core*' | ${XARGS} ${RM}
${RMRF} "${BUILD_BASE}/${BUILD_SUBDIR}"
${FIND} "${BASE_DIR}" -name '*.py[co]' -o -name 'core*' | ${XARGS} ${RM}
clobber: clean untestinst
${FIND} lib/python -name '*.so' | ${XARGS} ${RM}
${FIND} "${BASE_DIR}/lib/python" -name '*.so' | ${XARGS} ${RM}
......@@ -20,28 +20,28 @@ import sys
import versions
if sys.platform == 'win32':
TARGET_DIR = 'c:\\Zope-' + versions.ZOPE_MAJOR_VERSION
PREFIX = '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
PREFIX = '/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])))
# below assumes this script is in the BASE_DIR/inst directory
global PREFIX
BASE_DIR=os.path.abspath(os.path.dirname(os.path.dirname(sys.argv[0])))
BUILD_BASE=os.getcwd()
PYTHON=sys.executable
MAKEFILE=open(os.path.join(BUILD_DIR, 'inst', IN_MAKEFILE)).read()
MAKEFILE=open(os.path.join(BASE_DIR, 'inst', IN_MAKEFILE)).read()
REQUIRE_LF_ENABLED = 1
REQUIRE_ZLIB=1
OPT_FLAGS = ''
zope_home = TARGET_DIR
build_dir = BUILD_DIR
python = PYTHON
INSTALL_FLAGS = ''
DISTUTILS_OPTS = ''
try:
longopts = ["help", "ignore-largefile", "ignore-zlib", "prefix=",
"optimize"]
"build-base=", "optimize", "quiet"]
opts, args = getopt.getopt(sys.argv[1:], "h", longopts)
except getopt.GetoptError, v:
print v
......@@ -52,36 +52,38 @@ def main():
usage()
sys.exit()
if o == '--prefix':
zope_home=os.path.abspath(os.path.expanduser(a))
PREFIX=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'
INSTALL_FLAGS = '--optimize=1 --no-compile'
if o == '--build-base':
BUILD_BASE = a
if o == '--quiet':
DISTUTILS_OPTS = '-q'
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"
print " - Zope top-level binary directory will be %s." % PREFIX
if INSTALL_FLAGS:
print " - Distutils install flags will be '%s'" % INSTALL_FLAGS
idata = {
'<<PYTHON>>':python,
'<<TARGET_DIR>>':zope_home,
'<<BUILD_DIR>>':build_dir,
'<<OPT_FLAGS>>':OPT_FLAGS,
'<<PYTHON>>':PYTHON,
'<<PREFIX>>':PREFIX,
'<<BASE_DIR>>':BASE_DIR,
'<<BUILD_BASE>>':BUILD_BASE,
'<<INSTALL_FLAGS>>':INSTALL_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,
'<<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 = open(os.path.join(BUILD_BASE, 'makefile'), 'w')
f.write(MAKEFILE)
print " - Makefile written."
print
......@@ -109,14 +111,16 @@ Options:
--optimize compile Python files as .pyo files
instead of as .pyc files
Installation directories:
Directories:
--prefix=DIR install Zope files in DIR [%(zope_home)s]
--build-base=DIR use DIR to store temporary build files
--prefix=DIR install Zope files in DIR [%(TARGET_DIR)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})
""" % ({'program':sys.argv[0], 'TARGET_DIR':TARGET_DIR})
)
print usage
......
......@@ -45,7 +45,6 @@ import os
import sys
import distutils.core
from distutils.core import Extension
# This function collects setup information for one massive distutils
......@@ -65,6 +64,7 @@ def setup(name=None, author=None, cmdclass=None, **kwargs):
# globbing on data_files.
from distutils.command.install import install
from distutils.command.build import build
from distutils.command.install_data import install_data
from distutils.util import convert_path
......@@ -127,6 +127,27 @@ ZOPE_INSTALL_SCHEME = {
}
class ZopeInstall(install):
# give distutils install step knowledge about build file placement options
user_options = install.user_options + [
('build-base=', None, 'base directory for build library'),
('build-lib=', None, 'build directory for all distribution'),
('build-scripts=', None, 'build directory for scripts'),
('build-temp=', None, 'temporary build directory'),
]
build_scripts = None
build_temp = None
def run(self):
""" Override run to pass along build location info so
we can use custom build directories """
build = self.distribution.get_command_obj('build')
build.build_base = self.build_base
build.build_lib = self.build_lib
build.build_scripts = self.build_scripts
build.build_temp = self.build_temp
install.run(self)
def select_scheme(self, name):
"""
Override the default platform installation schemes, ignoring whatever
......@@ -150,20 +171,20 @@ class ZopeDistribution(distutils.core.Distribution):
distutils.core.Distribution.__init__(self, attrs)
self.cmdclass["install"] = ZopeInstall
self.cmdclass["install_data"] = ZopeInstallData
# presumes we're currently cd'ed to the build root directory
ZOPE_ROOT = os.path.abspath(os.getcwd())
# presumes this script lives in the 'inst' subdirectory of the base dir
BASE_DIR=os.path.abspath(os.path.dirname(os.path.dirname(sys.argv[0])))
AUTHOR = 'Zope Corporation and Contributors'
EXTENSIONCLASS_ROOT = os.path.join(ZOPE_ROOT, 'lib', 'Components', 'ExtensionClass')
EXTENSIONCLASS_ROOT = os.path.join(BASE_DIR, 'lib', 'Components',
'ExtensionClass')
EXTENSIONCLASS_SRCDIR = os.path.join(EXTENSIONCLASS_ROOT, 'src')
PACKAGES_ROOT = os.path.join(ZOPE_ROOT, 'lib', 'python')
EXTENSIONCLASS_INCLUDEDIRS = [EXTENSIONCLASS_SRCDIR]
# Most modules are in lib/python in the source distribution
PACKAGES_ROOT = os.path.join(BASE_DIR, 'lib', 'python')
os.chdir(PACKAGES_ROOT)
# AccessControl
setup(
name='AccessControl',
......@@ -997,19 +1018,19 @@ distutils.core.setup(
data_files=setup_info.get('data_files', []),
headers=setup_info.get('headers', []),
ext_modules=setup_info.get('ext_modules', []),
scripts=setup_info.get('scripts', []),
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)
os.chdir(BASE_DIR)
def skel_visit(skel, dirname, names):
if "CVS" in names:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment