[Zope-Checkins] CVS: Zope/inst - configure.py:1.1.2.6.2.1
Tres Seaver
tseaver@zope.com
Sun, 1 Sep 2002 22:06:23 -0400
Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv13607/inst
Modified Files:
Tag: tseaver-installer-rebranch
configure.py
Log Message:
New branch off of Chris' installer branch:
- Use 'python setup.py build_ext -b <ext. dir> -t <tmp dir.>' to
get extensions built, instead of 'compileall'.
- Make 'configure && make && make install' work from a separate
directory (leaves source tree "pristine").
- Factor 'configure.main()' logic into a separte configurator class.
=== Zope/inst/configure.py 1.1.2.6 => 1.1.2.6.2.1 ===
--- Zope/inst/configure.py:1.1.2.6 Thu Aug 29 12:38:14 2002
+++ Zope/inst/configure.py Sun Sep 1 22:06:23 2002
@@ -18,47 +18,124 @@
"""
import getopt, sys, os
-BUILD_DIR = os.path.abspath(os.path.split(os.path.dirname(sys.argv[0]))[0])
+SOURCE_DIR = os.path.abspath(os.path.split(os.path.dirname(sys.argv[0]))[0])
ZOPE_HOME = '/usr/local/zope'
PYTHON = sys.executable
-MAKEINSTANCE = open(os.path.join(BUILD_DIR, 'makeinstance.in')).read()
-MAKEFILE = open(os.path.join(BUILD_DIR, 'Makefile.in')).read()
-def main():
- REQUIRE_LF_ENABLED = 1
- zope_home = ZOPE_HOME
- build_dir = BUILD_DIR
- python = PYTHON
- try:
- longopts = ["help", "ignore-largefile", "prefix="]
- 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 REQUIRE_LF_ENABLED:
- test_largefile()
- print " - Zope top-level binary directory will be %s." % zope_home
- opts = {'python':python,'zope_home':zope_home,'build_dir':build_dir}
- mf = MAKEFILE % opts
- f = open('Makefile', 'w')
- f.write(mf)
- print " - Makefile written."
- mi = MAKEINSTANCE % opts
- f = open('makeinstance', 'w')
- f.write(mi)
- os.chmod('makeinstance', 0755)
- print " - 'makeinstance' script written."
- print
- print " Next, run 'make'."
- print
+MAKEINSTANCE = open(os.path.join(SOURCE_DIR, 'makeinstance.in')).read()
+MAKEFILE = open(os.path.join(SOURCE_DIR, 'Makefile.in')).read()
+
+class ZopeInstaller:
+
+ """ Manage construction of build files / hierarchy. """
+
+ def __init__(self, python, zope_home, source_dir, build_dir,
+ require_largefile=1):
+ self.python = python
+ self.zope_home = zope_home
+ self.source_dir = source_dir
+ self.build_dir = build_dir
+ self.require_largefile = require_largefile
+
+ def opts(self):
+
+ """ Build a dictionary used for string interpolation. """
+
+ return { 'python': self.python,
+ 'zope_home': self.zope_home,
+ 'source_dir': self.source_dir,
+ 'build_dir': self.build_dir,
+ }
+
+ def make_Makefile(self):
+
+ """ Write out 'Makefile' in 'build_dir' using our options."""
+
+ mf = MAKEFILE % self.opts()
+ f = open('Makefile', 'w')
+ f.write(mf)
+ print " - Makefile written."
+
+ def make_makeinstance(self):
+
+ """ Write out 'makeinstance' in 'build_dir' using our options."""
+
+ mi = MAKEINSTANCE % self.opts()
+ f = open('makeinstance', 'w')
+ f.write(mi)
+ os.chmod('makeinstance', 0755)
+ print " - 'makeinstance' script written."
+
+ def test_largefile(self):
+
+ """ Ensure that the current interpreter has largefile support."""
+ 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 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 database size
+ever exceeds 2GB.
+"""
+ )
+ sys.exit(127)
+
+ def initialize_build_tree(self):
+
+ """ Clone 'source_dir' into 'build_dir. """
+
+ return # Don't want to do this now!
+
+ print ( " - Cloning sources from:\n"
+ " %(source_dir)s:\n"
+ " into:\n"
+ " %(build_dir)s" % self.opts() )
+
+ os.path.walk( self.source_dir, self._copyFiles, None )
+
+ def _copyFiles( self, IGNORED, dirname, fnames ):
+
+ """ Callback for os.path.walk."""
+
+ OMIT = ( 'CVS', '.cvsignore' )
+ for omit in OMIT:
+ if omit in fnames:
+ fnames.remove( omit )
+
+ reldir = dirname[ len( self.source_dir ) + 1: ]
+ if reldir:
+ os.mkdir( os.path.join( self.build_dir, reldir ) )
+
+ for name in fnames:
+ src = os.path.join( dirname, name )
+ dest = os.path.join( self.build_dir, reldir, name )
+ if os.path.isfile( src ):
+ os.symlink( src, dest )
+
+ def __call__(self):
+ """ Do the setup. """
+
+ print ( " - Zope top-level binary directory will be:\n"
+ " %s." % self.zope_home )
+ self.make_Makefile()
+ self.make_makeinstance()
+ if self.require_largefile:
+ self.test_largefile()
+
+ if self.build_dir != self.source_dir:
+ self.initialize_build_tree()
def usage():
usage = ("""
@@ -86,31 +163,41 @@
)
print usage
-def test_largefile():
- OK=0
- f = open(sys.argv[0], 'r')
+def main():
+
+ require_largefile = 1
+ zope_home = ZOPE_HOME
+ source_dir = SOURCE_DIR
+ build_dir = os.getcwd()
+ python = PYTHON
+
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 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 database size
-ever exceeds 2GB.
-"""
- )
- sys.exit(127)
+ longopts = ["help", "ignore-largefile", "prefix="]
+ 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_largefile=0
+
+ ZopeInstaller(python=python,
+ zope_home=zope_home,
+ source_dir=source_dir,
+ build_dir=build_dir,
+ require_largefile=require_largefile,
+ )()
+ print
+ print " Next, run 'make'."
+ print
if __name__ == '__main__':
main()
-
+