[Checkins] SVN: zope.i18nmessageid/trunk/ Fixed the compilation of the C extension with python 2.6: refactored it as a setuptools Feature.

Fabio Tranchitella kobold at kobold.it
Wed Aug 5 07:23:58 EDT 2009


Log message for revision 102497:
  Fixed the compilation of the C extension with python 2.6: refactored it as a setuptools Feature.

Changed:
  U   zope.i18nmessageid/trunk/CHANGES.txt
  U   zope.i18nmessageid/trunk/setup.py

-=-
Modified: zope.i18nmessageid/trunk/CHANGES.txt
===================================================================
--- zope.i18nmessageid/trunk/CHANGES.txt	2009-08-05 10:27:46 UTC (rev 102496)
+++ zope.i18nmessageid/trunk/CHANGES.txt	2009-08-05 11:23:58 UTC (rev 102497)
@@ -5,7 +5,8 @@
 3.5.1 (unreleased)
 ------------------
 
-- ...
+- Fixed the compilation of the C extension with python 2.6: refactored it as a
+  setuptools Feature.
 
 3.5.0 (2009-06-27)
 ------------------

Modified: zope.i18nmessageid/trunk/setup.py
===================================================================
--- zope.i18nmessageid/trunk/setup.py	2009-08-05 10:27:46 UTC (rev 102496)
+++ zope.i18nmessageid/trunk/setup.py	2009-08-05 11:23:58 UTC (rev 102497)
@@ -1,3 +1,12 @@
+#!/usr/bin/python2.6
+
+import sys
+
+sys.path[0:0] = [
+  '/home/kobold/buildbot/ztk/zope.i18nmessageid-py2.6-64bit-linux/build/src',
+  '/home/kobold/.buildout/eggs/setuptools-0.6c9-py2.6.egg',
+]
+
 ##############################################################################
 #
 # Copyright (c) 2006 Zope Corporation and Contributors.
@@ -19,7 +28,7 @@
 import os
 import sys
 
-from setuptools import setup, find_packages, Extension
+from setuptools import setup, find_packages, Extension, Feature
 from distutils.command.build_ext import build_ext
 from distutils.errors import CCompilerError
 from distutils.errors import DistutilsExecError
@@ -28,36 +37,16 @@
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
-class optional_build_ext(build_ext):
-    """This class subclasses build_ext and allows
-       the building of C extensions to fail.
-    """
-    def run(self):
-        try:
-            build_ext.run(self)
-        
-        except DistutilsPlatformError, e:
-            self._unavailable(e)
+codeoptimization = Feature("Optional code optimizations",
+    standard=True,
+    ext_modules=[
+        Extension("zope.i18nmessageid._zope_i18nmessageid_message", [
+            os.path.join('src', 'zope', 'i18nmessageid',
+                "_zope_i18nmessageid_message.c")
+        ]),
+    ],
+)
 
-    def build_extension(self, ext):
-       try:
-           build_ext.build_extension(self, ext)
-        
-       except (CCompilerError, DistutilsExecError), e:
-           self._unavailable(e)
-
-    def _unavailable(self, e):
-        print >> sys.stderr, '*' * 80
-        print >> sys.stderr, """WARNING:
-
-        An optional code optimization (C extension) could not be compiled.
-
-        Optimizations for this package will not be available!"""
-        print >> sys.stderr
-        print >> sys.stderr, e
-        print >> sys.stderr, '*' * 80
-
-
 setup(name='zope.i18nmessageid',
     version = '3.5.1dev',
     author='Zope Corporation and Contributors',
@@ -85,16 +74,10 @@
     url='http://pypi.python.org/pypi/zope.i18nmessageid',
     packages=find_packages('src'),
     package_dir = {'': 'src'},
-    ext_modules=[
-        Extension("zope.i18nmessageid._zope_i18nmessageid_message",
-                  [os.path.join('src', 'zope', 'i18nmessageid',
-                                "_zope_i18nmessageid_message.c") ]),
-        ],
+    features = {'codeoptimization': codeoptimization},
     namespace_packages=['zope',],
     tests_require = ['zope.testing'],
     install_requires=['setuptools'],
     include_package_data = True,
     zip_safe = False,
-    cmdclass = {'build_ext':optional_build_ext},
-    )
-
+)



More information about the Checkins mailing list