Commits

Dinu Gherman  committed 7ef7fdf

Modified setup.py for building on Python 2/3.

  • Participants
  • Parent commits 053f1a9

Comments (0)

Files changed (1)

 
 import os
 import sys
-from distutils.core import setup
+
+# assume we have Distribute for Python 3, and Setuptools for Python 2
+if sys.version_info[0] >= 3:
+    from distribute_setup import use_setuptools
+    use_setuptools()
+    from setuptools import setup
+else:
+    from distutils.core import setup
 
 from eonums import __version__, __date__, __license__, __author__
 
 
 setupCommand = sys.argv[1]
 
-
 # first try converting README from ReST to HTML, if Docutils is installed
 # (else issue a warning)
 
     res = os.popen("which %s" % toolName).read().strip()
     if res.endswith(toolName):
         cmd = "%s '%s' '%s'" % (res, "README.txt", "README.html")
-        print "running command %s" % cmd
+        print("running command %s" % cmd)
         cmd = os.system(cmd)
     else:
-        print "Warning: No '%s' found. 'README.{txt|html}'" % toolName,
-        print "might be out of synch."
+        msg = "Warning: No '%s' found. 'README.{txt|html}' " % toolName
+        msg += "might be out of sync."
+        print(msg)
 
 
 # description for Distutils to do its business
 Esperanto naming rules by introducing names like "undekiliono",
 "undekiliardo", "dudekiliono" etc.)
 
-This module can be fully translated automatically to Python 3.0
-using its migration tool named ``2to3``.
+Version 0.9.1 now works on Python 2 and Python 3.
 
 
 Features
 - handle integers from 0 to 10**66 - 1
 - provide conversion functions and command-line scripts
 - provide a Unittest test suite
-- can be automatically migrated to Python 3.0 using ``2to3``
+- runs the same code under Python 2 and Python 3
 
 
 Examples
 ++++++++
 
-::
+Python 2::
 
     >>> from eonums import int2eo, eo2int, validate_eo
     >>>
     123
     >>> validate_eo(u"dudek cent tri")
     False
+
+
+Python 3::
+
+    >>> from eonums import int2eo, eo2int, validate_eo
+    >>>
+    >>> int2eo(22334455)
+    'dudek du milionoj tricent tridek kvar mil kvarcent kvindek kvin'
+    >>>
+    >>> eo2int("cent dudek tri")
+    123
+    >>> validate_eo("dudek cent tri")
+    False
+
+History
++++++++
+
+- 2008-09-15 (0.9.0): First official realease
+- 2012-06-20 (0.9.1): Adapted code to run on Python 2 and Python 3.
 """,
     date=__date__,
     author=__author__,
         "Natural Language :: English",
         "Natural Language :: Esperanto",
         "Operating System :: OS Independent",
-        "Programming Language :: Python",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 3",
         "Topic :: Education",
         "Topic :: Software Development",
     ],