[Zope-CVS] SVN: zpkgtools/trunk/zpkgsetup/setup.py - change how the debugging display is handled to avoid messing up the

Fred L. Drake, Jr. fdrake at gmail.com
Mon Aug 2 19:02:12 EDT 2004


Log message for revision 26868:
  - change how the debugging display is handled to avoid messing up the
    "build --debug" option.  This is now tied to the "debugdisplay" command
    instead of hinging on the presence of --debug anywhere in sys.argv.
  


Changed:
  U   zpkgtools/trunk/zpkgsetup/setup.py


-=-
Modified: zpkgtools/trunk/zpkgsetup/setup.py
===================================================================
--- zpkgtools/trunk/zpkgsetup/setup.py	2004-08-02 21:06:08 UTC (rev 26867)
+++ zpkgtools/trunk/zpkgsetup/setup.py	2004-08-02 23:02:12 UTC (rev 26868)
@@ -31,6 +31,8 @@
 import re
 import sys
 
+from distutils.cmd import Command
+
 from zpkgsetup import package
 from zpkgsetup import publication
 
@@ -105,18 +107,12 @@
         for name in self.__dict__:
             if name[0] == "_":
                 del kwargs[name]
-        if "--debug" in sys.argv:
-            import pprint
-            try:
-                pprint.pprint(kwargs)
-            except IOError, e:
-                if e.errno != errno.EPIPE:
-                    raise
-        else:
-            from zpkgsetup.dist import ZPkgDistribution
-            from distutils.core import setup
-            kwargs["distclass"] = ZPkgDistribution
-            setup(**kwargs)
+        from zpkgsetup.dist import ZPkgDistribution
+        from distutils.core import setup
+        kwargs["distclass"] = ZPkgDistribution
+        ContextDisplay.kwargs = kwargs
+        kwargs["cmdclass"] = {"debugdisplay": ContextDisplay}
+        setup(**kwargs)
 
     def load_metadata(self, path):
         f = open(path, "rU")
@@ -235,3 +231,27 @@
     def add_package_file(self, pkgname, relfn):
         L = self.package_data.setdefault(pkgname, [])
         L.append(relfn)
+
+
+class ContextDisplay(Command):
+    """Command to display the information being passed to setup()."""
+
+    # Note: The .kwargs attribute is set on this class by the setup()
+    # method above; this is a really hackish way to get the kwargs
+    # dict, but it works.
+
+    user_options = []
+
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
+    def run(self):
+        import pprint
+        try:
+            pprint.pprint(self.kwargs)
+        except IOError, e:
+            if e.errno != errno.EPIPE:
+                raise



More information about the Zope-CVS mailing list