[Zodb-checkins] CVS: ZODB3 - setup.py:1.24

Jeremy Hylton jeremy@zope.com
Tue, 5 Nov 2002 18:15:52 -0500


Update of /cvs-repository/ZODB3
In directory cvs.zope.org:/tmp/cvs-serv2954

Modified Files:
	setup.py 
Log Message:
Add ZConfig to list of installed packages.

This ends up requiring lots of messy code to get distutils to install
the test .conf files.


=== ZODB3/setup.py 1.23 => 1.24 ===
--- ZODB3/setup.py:1.23	Wed Oct 30 13:57:13 2002
+++ ZODB3/setup.py	Tue Nov  5 18:15:51 2002
@@ -20,9 +20,16 @@
 interface, rich transaction support, and undo.
 """
 
+import glob
+import os
 import sys
 from distutils.core import setup
 from distutils.extension import Extension
+from distutils import dir_util
+from distutils.core import setup
+from distutils.dist import Distribution
+from distutils.command.install_lib import install_lib
+from distutils.command.build_py import build_py
 
 ExtensionClass = Extension(name = 'ExtensionClass',
                            sources = ['ExtensionClass/src/ExtensionClass.c'])
@@ -115,6 +122,7 @@
             "zLOG", "zLOG.tests",
             "zdaemon", "zdaemon.tests",
             "ZopeUndo", "ZopeUndo.tests",
+            "ZConfig", "ZConfig.tests",
             ]
 
 package_dir = {}
@@ -169,6 +177,41 @@
                iib, iob, fsb,
                ]
 
+def copy_conf_files(cmd, outputbase):
+    inputdir = os.path.join("ZConfig", "tests", "input")
+    outputdir = os.path.join(outputbase, inputdir)
+    if not os.path.exists(outputdir):
+        dir_util.mkpath(outputdir)
+    for fn in glob.glob(os.path.join(inputdir, "*.conf")):
+        cmd.copy_file(fn, os.path.join(outputbase, fn))
+
+class MyLibInstaller(install_lib):
+    """Custom library installer, used to put hosttab in the right place."""
+    # We use the install_lib command since we need to put hosttab
+    # inside the library directory.  This is where we already have the
+    # real information about where to install it after the library
+    # location has been set by any relevant distutils command line
+    # options.
+
+    def run(self):
+        install_lib.run(self)
+        copy_conf_files(self, self.install_dir)
+
+class MyPyBuilder(build_py):
+    def build_packages(self):
+        build_py.build_packages(self)
+        copy_conf_files(self, self.build_lib)
+
+class MyDistribution(Distribution):
+    # To control the selection of MyLibInstaller and MyPyBuilder, we
+    # have to set it into the cmdclass instance variable, set in
+    # Distribution.__init__().
+
+    def __init__(self, *attrs):
+        Distribution.__init__(self, *attrs)
+        self.cmdclass['build_py'] = MyPyBuilder
+        self.cmdclass['install_lib'] = MyLibInstaller
+
 # Don't build the helper unless using at least Python 2.2
 if sys.hexversion >= 0x020200F0:
     ext_modules.append(bsddbhelper)
@@ -187,5 +230,6 @@
       license = "http://www.zope.org/Resources/ZPL",
       platforms = ["yes"], #
       description = doclines[0],
-      long_description = "\n".join(doclines[2:])
+      long_description = "\n".join(doclines[2:]),
+      distclass = MyDistribution,
       )