Luke Plant avatar Luke Plant committed a9828c0

Fairly hacky but functional Python3 support via 2to3

Comments (0)

Files changed (1)

 #!/usr/bin/env python
 from setuptools import setup, find_packages
 import os
-
+import sys
 
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
+extra = {}
+if sys.version_info >= (3,):
+    extra['use_2to3'] = True
+
+    import distutils.util
+    import setuptools
+    from lib2to3.refactor import get_fixers_from_package
+    fixer_names = []
+    for p in setuptools.lib2to3_fixer_packages:
+        fixer_names.extend(get_fixers_from_package(p))
+
+    # Modify
+    fixer_names.remove('lib2to3.fixes.fix_next')
+    # Monkey patch:
+    distutils.util.Mixin2to3.fixer_names = fixer_names
 
 setup(
     name = "playerdo",
         "Development Status :: 4 - Beta",
         "Intended Audience :: End Users/Desktop",
         "Operating System :: POSIX :: Linux",
-        ]
+        ],
+    **extra
 )
+
+
+# dbus isn't on PyPI, can't just put it in requirements
+try:
+    import dbus
+except ImportError:
+    sys.stderr.write("WARNING: Python 'dbus' library is not installed. Some backends will not work.\n")
+    if sys.version_info >= (3,):
+        sys.stderr.write("At the time of writing, a Python 3 dbus library is only available if you build the py3k branch available at http://cgit.freedesktop.org/dbus/dbus-python/ \n")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.