git_remote_helpers: use 2to3 if building with Python 3

Using the approach detailed in the Python documentation[1], run 2to3 on the code as part of the build if building with Python 3. The code itself requires no changes to convert cleanly. [1] http://docs.python.org/3.3/howto/pyporting.html#during-installation Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Keeping committed Jan 20, 2013 at 13:15 UTC 62c814b6b60f5b5605e34c9806d874fe1088d416
1 file changed +10
git_remote_helpers/setup.py
+10
@@ -4,6 +4,15 @@
4
5 from distutils.core import setup
6
7 +# If building under Python3 we need to run 2to3 on the code, do this by
8 +# trying to import distutils' 2to3 builder, which is only available in
9 +# Python3.
10 +try:
11 + from distutils.command.build_py import build_py_2to3 as build_py
12 +except ImportError:
13 + # 2.x
14 + from distutils.command.build_py import build_py
15 +
16 setup(
17 name = 'git_remote_helpers',
18 version = '0.1.0',
@@ -14,4 +23,5 @@ setup(
23 url = 'http://www.git-scm.com/',
24 package_dir = {'git_remote_helpers': ''},
25 packages = ['git_remote_helpers', 'git_remote_helpers.git'],
26 + cmdclass = {'build_py': build_py},
27 )