[PATCH] [CORRECTED] setup.py: Workaround for missing bz2 module in IronPython
Matt Mackall
mpm at selenic.com
Mon May 9 13:34:29 CDT 2011
On Mon, 2011-05-09 at 11:12 -0400, Zachary Gramana wrote:
> # HG changeset patch
> # User Zachary Gramana <zgramana at pottsconsultinggroup.com>
> # Date 1304953813 14400
> # Node ID 47d9c9b614f31463ae5b699376d35196afb41dce
> # Parent 332c5ea29ff0bbed408e6b2b035397fabe2dfcd7
> setup.py: Workaround for missing bz2 module in IronPython
>
> IronPython does not provide the bz2 module on its own. This patch skips
> importing it to allow setup to continue.
Surely this can't be the best way of detecting IronPython?
Here are some alternatives that seem slightly better:
http://stackoverflow.com/questions/2795240/best-way-to-detect-ironpython
Also, we avoid using camelCase (exceptions being a notable exception).
> diff -r 332c5ea29ff0 -r 47d9c9b614f3 setup.py
> --- a/setup.py Mon May 09 11:02:02 2011 -0400
> +++ b/setup.py Mon May 09 11:10:13 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,22 @@
> raise SystemExit(
> "Couldn't import standard zlib (incomplete Python install).")
>
> +# The base IronPython distribution (as of 2.7.1) doesn't support bz2
> try:
> - import bz2
> -except:
> - raise SystemExit(
> - "Couldn't import standard bz2 (incomplete Python install).")
> + isIronPython = os.path.split(sys.executable)[1] == "ipy.exe"
> +except:
> + 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
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list