Commits

Jakub Wilk committed 9c6b02c

Build Py3K version automatically.

Comments (0)

Files changed (2)

 License :: OSI Approved :: GNU General Public License (GPL)
 Operating System :: OS Independent
 Programming Language :: Python
+Programming Language :: Python :: 2
+Programming Language :: Python :: 3
 Topic :: Software Development :: Libraries :: Python Modules
 Topic :: Text Processing :: Filters
 '''.strip().split('\n')
 import os
 import distutils.core
 
+try:
+    # Python 3.X
+    from distutils.command.build_py import build_py_2to3 as distutils_build_py
+except ImportError:
+    # Python 2.X
+    from distutils.command.build_py import build_py as distutils_build_py
+
 os.putenv('TAR_OPTIONS', '--owner root --group root --mode a+rX')
 
 distutils.core.setup(
     url = 'http://jwilk.net/software/python-elinks',
     author = 'Jakub Wilk',
     author_email = 'jwilk@jwilk.net',
-    packages = ['elinks']
+    packages = ['elinks'],
+    cmdclass = dict(build_py=distutils_build_py),
 )
 
 # vim:ts=4 sw=4 et
 
 import elinks
 
+try:
+    unicode
+except NameError:
+    # Python 3.X
+    def u(s):
+        return s
+    def b(s):
+        return s.encode('UTF-8')
+else:
+    # Python 2.X
+    def u(s):
+        return s.decode('UTF-8')
+    def b(s):
+        return s
+
 def test_elinks():
-    s = u'Różowy słoń nie zechce usiąść na tępych gwoździach…'
-    t = 'Rozowy sl/on nie zechce usiasc na tepych gwozdziach...'
-    assert s.encode('ASCII', 'elinks') == t
+    s = u('Różowy słoń nie zechce usiąść na tępych gwoździach…')
+    t = b('Rozowy sl/on nie zechce usiasc na tepych gwozdziach...')
+    encoded_s = s.encode('ASCII', 'elinks')
+    assert encoded_s == t , '%r != %r' % (encoded_s, t)
 
 if __name__ == '__main__':
     test_elinks()