[PATCH] setup.py: Workaround for missing bz2 module in IronPython

Augie Fackler durin42 at gmail.com
Mon May 9 09:52:48 CDT 2011


On Mon, May 9, 2011 at 9:01 AM, Zachary Gramana
<zgramana at pottsconsultinggroup.com> wrote:
> # HG changeset patch
> # User Zachary Gramana <zgramana at pottsconsultinggroup.com>
> # Date 1304949224 14400
> # Node ID 1f6b3f2388e5e029999a0b17014f0eaa8dd1641b
> # Parent  7733e9df43db0a011c866446350c68529e8ecd7c
> setup.py: Workaround for missing bz2 module in IronPython
>
> IronPython does not provide the bz2 module on its own.  This patch skips
> importing the bz2 module.

OOC, Is there any particular reason IronPython is broken in this respect?

>
> diff -r 7733e9df43db -r 1f6b3f2388e5 setup.py
> --- a/setup.py  Mon May 09 09:38:37 2011 -0400
> +++ b/setup.py  Mon May 09 09:53:44 2011 -0400
> @@ -4,7 +4,7 @@
>  # 'python setup.py install', or
>  # 'python setup.py --help' for more options
>
> -import sys
> +import sys, os
>  if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0,
> 'final'):
>     raise SystemExit("Mercurial requires Python 2.4 or later.")
>
> @@ -36,13 +36,21 @@
>     raise SystemExit(
>         "Couldn't import standard zlib (incomplete Python install).")
>
> -try:
> -    import bz2
> -except:
> -    raise SystemExit(
> -        "Couldn't import standard bz2 (incomplete Python install).")
> +# The base IronPython distribution (as of 2.7.1) doesn't support bz2
> + try:
> +    isIronPython =  os.path.split(sys.executable)[1] == "ipy.exe"
> +    pass
> +else:
> +    if isIronPython:
> +        print "(IronPython detected. Skipping bz2 import.)"
> +    else:
> +        try:
> +            import bz2
> +        except:
> +            raise SystemExit(
> +                "Couldn't import standard bz2 (incomplete Python
> install).")
>
> -import os, subprocess, time
> +import subprocess, time
>  import shutil
>  import tempfile
>  from distutils import log
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
>


More information about the Mercurial-devel mailing list