[Checkins] SVN: zope.optionalextension/trunk/src/zope/optionalextension/ Make the package work as a distutils 'command_packages' plugin.

Tres Seaver tseaver at palladion.com
Sat Jul 3 14:53:32 EDT 2010


Log message for revision 114145:
  Make the package work as a distutils 'command_packages' plugin.

Changed:
  D   zope.optionalextension/trunk/src/zope/optionalextension/__init__.py
  A   zope.optionalextension/trunk/src/zope/optionalextension/build_ext.py
  U   zope.optionalextension/trunk/src/zope/optionalextension/tests/__init__.py
  A   zope.optionalextension/trunk/src/zope/optionalextension/tests/test_build_ext.py
  D   zope.optionalextension/trunk/src/zope/optionalextension/tests/test_command.py

-=-
Deleted: zope.optionalextension/trunk/src/zope/optionalextension/__init__.py
===================================================================
--- zope.optionalextension/trunk/src/zope/optionalextension/__init__.py	2010-07-03 18:32:36 UTC (rev 114144)
+++ zope.optionalextension/trunk/src/zope/optionalextension/__init__.py	2010-07-03 18:53:31 UTC (rev 114145)
@@ -1,53 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-from distutils.command.build_ext import build_ext
-from distutils.errors import CCompilerError
-from distutils.errors import DistutilsExecError
-from distutils.errors import DistutilsPlatformError
-import sys
-from traceback import format_exc
- 
- 
-class optional_build_ext(build_ext):
-    """ Allow building of C extensions to fail without blocking installation.
-    """
-    description = __doc__
-
-    def __init__ (self, dist, stream=None):
-        build_ext.__init__(self, dist)
-        if stream is None:
-            stream = sys.stderr
-        self._stream = stream
-
-    def run(self):
-        try:
-            build_ext.run(self)
-        except DistutilsPlatformError, e:
-            self._unavailable(e)
-
-    def build_extension(self, ext):
-        try:
-            build_ext.build_extension(self, ext)
-        except (CCompilerError, DistutilsExecError), e:
-            self._unavailable(e)
-
-    def _unavailable(self, e):
-        self._stream.write('%s\n' % ('*' * 80))
-        self._stream.write("""WARNING:
-
-        An optional code optimization (C extension) could not be compiled.
-        """)
-        self._stream.write('\n')
-        self._stream.write('%s\n' % format_exc(e))
-        self._stream.write('%s\n' % ('*' * 80))

Copied: zope.optionalextension/trunk/src/zope/optionalextension/build_ext.py (from rev 114143, zope.optionalextension/trunk/src/zope/optionalextension/__init__.py)
===================================================================
--- zope.optionalextension/trunk/src/zope/optionalextension/build_ext.py	                        (rev 0)
+++ zope.optionalextension/trunk/src/zope/optionalextension/build_ext.py	2010-07-03 18:53:31 UTC (rev 114145)
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+from distutils.command.build_ext import build_ext
+from distutils.errors import CCompilerError
+from distutils.errors import DistutilsExecError
+from distutils.errors import DistutilsPlatformError
+import sys
+from traceback import format_exc
+ 
+ 
+class optional_build_ext(build_ext):
+    """ Allow building of C extensions to fail without blocking installation.
+    """
+    description = __doc__
+
+    def __init__ (self, dist, stream=None):
+        build_ext.__init__(self, dist)
+        if stream is None:
+            stream = sys.stderr
+        self._stream = stream
+
+    def run(self):
+        try:
+            build_ext.run(self)
+        except DistutilsPlatformError, e:
+            self._unavailable(e)
+
+    def build_extension(self, ext):
+        try:
+            build_ext.build_extension(self, ext)
+        except (CCompilerError, DistutilsExecError), e:
+            self._unavailable(e)
+
+    def _unavailable(self, e):
+        self._stream.write('%s\n' % ('*' * 80))
+        self._stream.write("""WARNING:
+
+        An optional code optimization (C extension) could not be compiled.
+        """)
+        self._stream.write('\n')
+        self._stream.write('%s\n' % format_exc(e))
+        self._stream.write('%s\n' % ('*' * 80))

Modified: zope.optionalextension/trunk/src/zope/optionalextension/tests/__init__.py
===================================================================
--- zope.optionalextension/trunk/src/zope/optionalextension/tests/__init__.py	2010-07-03 18:32:36 UTC (rev 114144)
+++ zope.optionalextension/trunk/src/zope/optionalextension/tests/__init__.py	2010-07-03 18:53:31 UTC (rev 114145)
@@ -1 +1,13 @@
-# package
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################

Copied: zope.optionalextension/trunk/src/zope/optionalextension/tests/test_build_ext.py (from rev 114143, zope.optionalextension/trunk/src/zope/optionalextension/tests/test_command.py)
===================================================================
--- zope.optionalextension/trunk/src/zope/optionalextension/tests/test_build_ext.py	                        (rev 0)
+++ zope.optionalextension/trunk/src/zope/optionalextension/tests/test_build_ext.py	2010-07-03 18:53:31 UTC (rev 114145)
@@ -0,0 +1,58 @@
+import unittest
+
+class Test_optional_build_ext(unittest.TestCase):
+
+    def _getTargetClass(self):
+        from zope.optionalextension.build_ext import optional_build_ext
+        return optional_build_ext
+
+    def _makeOne(self, dist=None, stream=None):
+        if dist is None:
+            dist = self._makeDistribution()
+        if stream is None:
+            stream = self._makeStream()
+        command = self._getTargetClass()(dist, stream)
+        command.initialize_options()
+        command.finalize_options()
+        return command
+
+    def _makeDistribution(self):
+        from distutils.core import Distribution
+
+        class DummyDistribution(Distribution):
+
+            def has_c_libraries(self):
+                return True
+
+        return DummyDistribution()
+
+    def _makeExtension(self, name, sources):
+        from distutils.core import Extension
+
+        class DummyExtension(Extension):
+            pass
+
+        return DummyExtension(name, sources)
+
+    def _makeStream(self):
+        from StringIO import StringIO
+        return StringIO()
+
+    def test_run(self):
+        command = self._makeOne()
+        command.extensions = [self._makeExtension('aaa', ['foo.c'])]
+        command.run() # doesn't raise
+        self.failUnless('CompileError' in command._stream.getvalue())
+
+    def test_build_extension(self):
+        command = self._makeOne()
+        command.compiler = DummyCompiler()
+        ext = self._makeExtension('aaa', ['foo.c'])
+        command.build_extension(ext) # doesn't raise
+        self.failUnless('TESTING' in command._stream.getvalue())
+
+
+class DummyCompiler:
+    def compile(self, *args, **kw):
+        from distutils.errors import CCompilerError
+        raise CCompilerError('TESTING')

Deleted: zope.optionalextension/trunk/src/zope/optionalextension/tests/test_command.py
===================================================================
--- zope.optionalextension/trunk/src/zope/optionalextension/tests/test_command.py	2010-07-03 18:32:36 UTC (rev 114144)
+++ zope.optionalextension/trunk/src/zope/optionalextension/tests/test_command.py	2010-07-03 18:53:31 UTC (rev 114145)
@@ -1,58 +0,0 @@
-import unittest
-
-class Test_optional_build_ext(unittest.TestCase):
-
-    def _getTargetClass(self):
-        from zope.optionalextension import optional_build_ext
-        return optional_build_ext
-
-    def _makeOne(self, dist=None, stream=None):
-        if dist is None:
-            dist = self._makeDistribution()
-        if stream is None:
-            stream = self._makeStream()
-        command = self._getTargetClass()(dist, stream)
-        command.initialize_options()
-        command.finalize_options()
-        return command
-
-    def _makeDistribution(self):
-        from distutils.core import Distribution
-
-        class DummyDistribution(Distribution):
-
-            def has_c_libraries(self):
-                return True
-
-        return DummyDistribution()
-
-    def _makeExtension(self, name, sources):
-        from distutils.core import Extension
-
-        class DummyExtension(Extension):
-            pass
-
-        return DummyExtension(name, sources)
-
-    def _makeStream(self):
-        from StringIO import StringIO
-        return StringIO()
-
-    def test_run(self):
-        command = self._makeOne()
-        command.extensions = [self._makeExtension('aaa', ['foo.c'])]
-        command.run() # doesn't raise
-        self.failUnless('CompileError' in command._stream.getvalue())
-
-    def test_build_extension(self):
-        command = self._makeOne()
-        command.compiler = DummyCompiler()
-        ext = self._makeExtension('aaa', ['foo.c'])
-        command.build_extension(ext) # doesn't raise
-        self.failUnless('TESTING' in command._stream.getvalue())
-
-
-class DummyCompiler:
-    def compile(self, *args, **kw):
-        from distutils.errors import CCompilerError
-        raise CCompilerError('TESTING')



More information about the checkins mailing list