[Checkins] SVN: zope.i18nmessageid/branches/regebro-python3/setup.py Fixing up setup.py so tests run (but fail)

Lennart Regebro regebro at gmail.com
Fri Nov 19 05:31:46 EST 2010


Log message for revision 118481:
  Fixing up setup.py so tests run (but fail)

Changed:
  U   zope.i18nmessageid/branches/regebro-python3/setup.py

-=-
Modified: zope.i18nmessageid/branches/regebro-python3/setup.py
===================================================================
--- zope.i18nmessageid/branches/regebro-python3/setup.py	2010-11-19 10:21:29 UTC (rev 118480)
+++ zope.i18nmessageid/branches/regebro-python3/setup.py	2010-11-19 10:31:45 UTC (rev 118481)
@@ -28,6 +28,16 @@
 from distutils.errors import DistutilsExecError
 from distutils.errors import DistutilsPlatformError
 
+if sys.version_info >= (3,):
+    extra = dict(use_2to3 = True,
+                 convert_2to3_doctests = [
+                     'src/zope/i18messageis/messages.txt',
+                     ],
+                 dependency_links = ['.'],
+                 )
+else:
+    extra = {}
+
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
@@ -39,26 +49,33 @@
         try:
             build_ext.run(self)
         
-        except DistutilsPlatformError, e:
-            self._unavailable(e)
+        except DistutilsPlatformError:
+            # The sys.exc_info()[1] is to preserve compatibility with both
+            # Python 2.5 and 3.x, which is needed in setup.py.
+            self._unavailable(sys.exc_info()[1])
 
     def build_extension(self, ext):
         try:
             build_ext.build_extension(self, ext)
         
-        except (CCompilerError, DistutilsExecError), e:
-            self._unavailable(e)
+        except (CCompilerError, DistutilsExecError):
+            # The sys.exc_info()[1] is to preserve compatibility with both
+            # Python 2.5 and 3.x, which is needed in setup.py.
+            self._unavailable(sys.exc_info()[1])
 
     def _unavailable(self, e):
-        print >> sys.stderr, '*' * 80
-        print >> sys.stderr, """WARNING:
+        # Write directly to stderr to preserve compatibility with both
+        # Python 2.5 and 3.x, which is needed in setup.py.
+        sys.stderr.write('*' * 80 + '\n')
+        sys.stderr.write("""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
+        Optimizations for this package will not be available!
+        
+        """)
+        sys.stderr.write(str(e) + '\n')
+        sys.stderr.write('*' * 80 + '\n')
 
 
 setup(name='zope.i18nmessageid',
@@ -99,5 +116,6 @@
     test_suite='zope.i18nmessageid.tests.test_suite',
     zip_safe = False,
     cmdclass = {'build_ext':optional_build_ext},
+    **extra
     )
 



More information about the checkins mailing list