[PATCH v3 4/8] git_remote_helpers: Use 2to3 if building with Python 3
- From
John Keeping <john@keeping.me.uk>
- Date
- Jan 20, 2013, 13:15 UTC
- Message-ID
- <821f662a13db72ef96a9026133e8cb763c0a9be2.1358686905.git.john@keeping.me.uk>
- In-Reply-To
- <cover.1358686905.git.john@keeping.me.uk>
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> ---
On Fri, 18 Jan 2013 23:52:16 -0800, Sverre Rabbelier wrote:
> Assuming you tried this out on both 2.x and 3.x: > > Acked-by: Sverre Rabbelier <srabbelier@gmail.com>
I ran the test suite with Python 2.7.3 and 3.2.3.
git_remote_helpers/setup.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/git_remote_helpers/setup.py b/git_remote_helpers/setup.py index 4d434b6..6de41de 100644 --- a/git_remote_helpers/setup.py +++ b/git_remote_helpers/setup.py @@ -4,6 +4,15 @@ from distutils.core import setup +# If building under Python3 we need to run 2to3 on the code, do this by +# trying to import distutils' 2to3 builder, which is only available in +# Python3. +try: + from distutils.command.build_py import build_py_2to3 as build_py +except ImportError: + # 2.x + from distutils.command.build_py import build_py + setup( name = 'git_remote_helpers', version = '0.1.0', @@ -14,4 +23,5 @@ setup( url = 'http://www.git-scm.com/', package_dir = {'git_remote_helpers': ''}, packages = ['git_remote_helpers', 'git_remote_helpers.git'], + cmdclass = {'build_py': build_py}, )
-- 1.8.1.353.gc992d5a.dirty