[Zope3-checkins] CVS: Zope3 - setup.py:1.14

Barry Warsaw barry@wooz.org
Fri, 20 Dec 2002 10:47:05 -0500


Update of /cvs-repository/Zope3
In directory cvs.zope.org:/tmp/cvs-serv14374

Modified Files:
	setup.py 
Log Message:
Cleanups and comments.


=== Zope3/setup.py 1.13 => 1.14 ===
--- Zope3/setup.py:1.13	Fri Dec 20 10:34:43 2002
+++ Zope3/setup.py	Fri Dec 20 10:47:04 2002
@@ -22,10 +22,9 @@
 
 import os
 import sys
-import glob
 
-# provide a bunch of custom components that make it possible to install a non
-# .py file into one of the packages
+# Provide a bunch of custom components that make it possible to build and
+# install non-.py files into the package destinations.
 from distutils import dir_util
 from distutils.command.build import build as buildcmd
 from distutils.command.install_lib import install_lib as installcmd
@@ -34,7 +33,7 @@
 from distutils.extension import Extension
 
 
-# A hack to determine if Extension objects support the depends keyword arg,
+# A hack to determine if Extension objects support the `depends' keyword arg,
 # which only exists in Python 2.3's distutils.
 if not "depends" in Extension.__init__.func_code.co_varnames:
     # If it doesn't, create a local replacement that removes depends from the
@@ -55,15 +54,23 @@
         ]
 
 
+# This class serves multiple purposes.  It walks the file system looking for
+# auxiliary files that distutils doesn't install properly, and it actually
+# copies those files (when hooked into by distutils).  It also walks the file
+# system looking for candidate packages for distutils to install as normal.
+# The key here is that the package must have an __init__.py file.
 class Finder:
     def __init__(self, exts, prefix):
         self._files = []
         self._pkgs = {}
         self._exts = exts
+        # We're finding packages in lib/python in the source dir, but we're
+        # copying them directly under build/lib.<plat>.  So we need to lop off
+        # the prefix when calculating the package names from the file names.
         self._plen = len(prefix)
 
     def visit(self, ignore, dir, files):
-        for file in files[:]:
+        for file in files:
             # First see if this is one of the packages we want to add, or if
             # we're really skipping this package.
             if '__init__.py' in files:
@@ -87,11 +94,21 @@
         return self._pkgs.keys()
 
 
+# Create the finder instance, which will be used in lots of places.  `finder'
+# is the global we're most interested in.
 basedir = 'lib/python/'
 finder = Finder(EXTS, basedir)
 os.path.walk(basedir, finder.visit, None)
 packages = finder.get_packages()
 
+# The logging package is standard in Python 2.3.  Don't include it unless
+# we're building a source distribution.
+if 'sdist' not in sys.argv:
+    if sys.hexversion >= 0x02030000:
+        packages.remove('logging')
+
+
+# Distutils hook classes
 class MyBuilder(buildcmd):
     def run(self):
         buildcmd.run(self)
@@ -102,7 +119,6 @@
         installcmd.run(self)
         extra.copy_files(self, self.install_dir)
 
-
 class MyDistribution(Distribution):
     # To control the selection of MyLibInstaller and MyPyBuilder, we
     # have to set it into the cmdclass instance variable, set in
@@ -113,15 +129,7 @@
         self.cmdclass['install_lib'] = MyLibInstaller
 
 
-# The logging package is standard in Python 2.3.  Don't include it unless
-# we're building a source distribution.
-if 'sdist' not in sys.argv:
-    if sys.hexversion >= 0x02030000:
-        packages.remove('logging')
-
-
-doclines = __doc__.split("\n")
-
+# Set up dependencies for the BTrees package
 base_btrees_depends = [
     "lib/python/Persistence/cPersistence.h",
     "lib/python/Persistence/cPersistenceAPI.h",
@@ -154,9 +162,13 @@
         kwargs["define_macros"] = [('EXCLUDE_INTSET_SUPPORT', None)]
     return Extension(name, sources, **kwargs)
 
+# All Zope3 extension modules must be listed here.
 ext_modules = [
-    BTreeExtension("OO"), BTreeExtension("IO"), BTreeExtension("OI"),
-    BTreeExtension("II"), BTreeExtension("fs"),
+    BTreeExtension("OO"),
+    BTreeExtension("IO"),
+    BTreeExtension("OI"),
+    BTreeExtension("II"),
+    BTreeExtension("fs"),
     Extension("Persistence.cPersistence",
               ["lib/python/Persistence/cPersistence.c"],
               depends = ["lib/python/Persistence/cPersistence.h",
@@ -176,16 +188,19 @@
               depends = ["lib/python/Zope/Proxy/proxy.h"]),
     ]
 
+# On Window, there are more extensions that need to be built
 if sys.platform == "win32":
     ext_modules += [Extension("ZODB.winlock", ["lib/python/ZODB/winlock.c"])]
 
+
+# We're using the module docstring as the distutils descriptions.
 doclines = __doc__.split("\n")
 
 setup(name="Zope3",
       version="3.0a1",
       maintainer="Zope Corporation",
       maintainer_email="zope3-dev@zope.org",
-      url = "http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/FrontPage",
+      url = "http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture",
       ext_modules = ext_modules,
       # This doesn't work right at all
       headers = ["lib/python/Persistence/cPersistence.h",