[Checkins] SVN: zope.interface/trunk/ Under PyPy, 'zope.interface' should not build its C extension.

Tres Seaver tseaver at palladion.com
Tue Jul 5 15:13:40 EDT 2011


Log message for revision 122115:
  Under PyPy, 'zope.interface' should not build its C extension.
  
  PyPy's C extension compatibility layer is known to be slow, and defeats
  JIT optimization opportunities.
  
  Also, prevent attempting to build the extension under Jython, where it is
  flat impossible.
  
  Fixes LP #804832. 
  

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

-=-
Modified: zope.interface/trunk/CHANGES.txt
===================================================================
--- zope.interface/trunk/CHANGES.txt	2011-07-05 17:08:38 UTC (rev 122114)
+++ zope.interface/trunk/CHANGES.txt	2011-07-05 19:13:40 UTC (rev 122115)
@@ -4,7 +4,8 @@
 3.6.5 (unreleased)
 ------------------
 
-- TBD
+- LP #804832:  Under PyPy, ``zope.interface`` should not build its C
+  extension.  Also, prevent attempting to build it under Jython.
 
 3.6.4 (2011-07-04)
 ------------------

Modified: zope.interface/trunk/setup.py
===================================================================
--- zope.interface/trunk/setup.py	2011-07-05 17:08:38 UTC (rev 122114)
+++ zope.interface/trunk/setup.py	2011-07-05 19:13:40 UTC (rev 122115)
@@ -19,7 +19,9 @@
 """Setup for zope.interface package
 """
 
-import os, sys
+import os
+import platform
+import sys
 
 try:
     from setuptools import setup, Extension, Feature
@@ -39,16 +41,26 @@
         extra = {}
 
 else:
-    codeoptimization = Feature("Optional code optimizations",
-                               standard = True,
-                               ext_modules = [Extension(
-                                             "zope.interface._zope_interface_coptimizations",
-                                             [os.path.normcase(
-                                             os.path.join('src', 'zope',
-                                             'interface',
-                                             '_zope_interface_coptimizations.c')
-                                             )]
-                                             )])
+    codeoptimization_c = os.path.join('src', 'zope', 'interface',
+                                      '_zope_interface_coptimizations.c')
+    codeoptimization = Feature(
+            "Optional code optimizations",
+            standard = True,
+            ext_modules = [Extension(
+                           "zope.interface._zope_interface_coptimizations",
+                           [os.path.normcase(codeoptimization_c)]
+                          )])
+    py_impl = getattr(platform, 'python_implementation', lambda: None)
+    is_pypy = py_impl() == 'PyPy'
+    is_jython = 'java' in sys.platform
+
+    # Jython cannot build the C optimizations, while on PyPy they are
+    # anti-optimizations (the C extension compatibility layer is known-slow,
+    # and defeats JIT opportunities).
+    if is_pypy or is_jython:
+        features = {}
+    else:
+        features = {'codeoptimization': codeoptimization}
     extra = dict(
         namespace_packages=["zope"],
         include_package_data = True,
@@ -56,7 +68,7 @@
         tests_require = [],
         install_requires = ['setuptools'],
         extras_require={'docs': ['z3c.recipe.sphinxdoc']},
-        features = {'codeoptimization': codeoptimization}
+        features = features
         )
 
 def read(*rnames):



More information about the checkins mailing list