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

Zachary Gramana zgramana at pottsconsultinggroup.com
Wed May 11 14:02:50 CDT 2011


I apologize for the whitespace issues.  I've tried a number of things to 
remediate it, but I'm fresh out of ideas.

FWIW, I'm on Windows 7 (\r\n), and Thunderbird is set to send plaintext 
UTF-8.  The patches were either exported from hg, then copy-n-pasted 
into Thunderbird, or copied directly to the clipboard in TortoiseHg and 
pasted into Thunderbird. Committed code was edited from the working copy 
with Notepad++ with tabs set to insert 4 spaces.

I'm probably just missing that will be obvious to others. All 
suggestions are welcomed.

On 5/11/2011 1:42 PM, Matt Mackall wrote:
> On Mon, 2011-05-09 at 15:19 -0400, Zachary Gramana wrote:
>> # HG changeset patch
>> # User Zachary Gramana<zgramana at pottsconsultinggroup.com>
>> # Date 1304968616 14400
>> # Node ID ea286e93febc91d47ef80acc8a6ab8f6547960e3
>> # Parent  1256ac0f27b305d966a14b4b9f4e5e95d7bbf494
>> setup.py: Workaround for missing bz2 module in IronPython
>
> This patch had a bunch of weird whitespace damage, so it took me a bit
> to get around to it. I've queued your fix with some minor tweaks,
> thanks.
>
>> IronPython does not provide the bz2 module on its own.  This patch skips
>> importing it to allow setup to continue.
>>
>> diff -r 1256ac0f27b3 -r ea286e93febc setup.py
>> --- a/setup.py	Mon May 09 15:14:16 2011 -0400
>> +++ b/setup.py	Mon May 09 15:16:56 2011 -0400
>> @@ -4,7 +4,7 @@
>>    # 'python setup.py install', or
>>    # 'python setup.py --help' for more options
>>
>> -import sys
>> +import sys, platform
>>    if not hasattr(sys, 'version_info') or sys.version_info<  (2, 4, 0,
>> 'final'):
>>        raise SystemExit("Mercurial requires Python 2.4 or later.")
>>
>> @@ -36,11 +36,20 @@
>>        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 =
>> platform.python_implementation().lower().find("ironpython") != -1
>> +except:
>> +    pass
>> +else:
>> +    if isironpython:
>> +        print "warning: 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 shutil
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
>


More information about the Mercurial-devel mailing list