[PATCH 5 of 7] setup: support executing with python3 including 2to3

Mads Kiilerich mads at kiilerich.com
Tue Nov 8 17:07:29 CST 2011


Simon Heimberg wrote, On 11/08/2011 11:36 PM:
> # HG changeset patch
> # User Simon Heimberg<simohe at besonet.ch>
> # Date 1313933023 -7200
> # Node ID 52ba1200de770ab5bb2c600f03ee9eca4a77ac4c
> # Parent  287a7c88281cbe54abb385305ba188afdaa8e1fe
> setup: support executing with python3 including 2to3
>
> Merge the code from contrib/setup3.py in setup.
> The argument for executing is marked as experimental.
>
> Reason: The file in contrib was outdated (packages, cmdclass, ...)
>
> diff -r 287a7c88281c -r 52ba1200de77 setup.py
> --- a/setup.py	Die Nov 01 20:13:53 2011 +0100
> +++ b/setup.py	Son Aug 21 15:23:43 2011 +0200
> @@ -44,7 +44,8 @@
>       pass
>
>   if isironpython:
> -    print "warning: IronPython detected (no bz2 support)"
> +    # print statement is not compatible to python3
> +    eval('print "warning: IronPython detected (no bz2 support)"', {})

Wouldn't

     print("warning: IronPython detected (no bz2 support)")

work everywhere?

>   else:
>       try:
>           import bz2
> @@ -68,6 +69,18 @@
>   from distutils.sysconfig import get_python_inc
>   from distutils.version import StrictVersion
>
> +convert2to3 = '--c2to3' in sys.argv
> +if convert2to3:
> +    try:
> +        from distutils.command.build_py import build_py_2to3 as build_py
> +        from lib2to3.refactor import get_fixers_from_package as getfixers
> +    except ImportError:
> +        if sys.version_info[0]<  3:
> +            raise SystemExit("--c2to3 is only compatible with python3.")
> +        raise
> +    sys.path.append('contrib')

Shouldn't we also fail badly if python3 is used without --c2to3?

/Mads




More information about the Mercurial-devel mailing list