[PATCH] setup.py: Workaround for missing bz2 module in IronPython
Zachary Gramana
zgramana at pottsconsultinggroup.com
Mon May 9 11:34:39 CDT 2011
On 5/9/2011 12:05 PM, Augie Fackler wrote:
> On Mon, May 9, 2011 at 11:02 AM, Zachary Gramana
> <zgramana at pottsconsultinggroup.com> wrote:
>> That's a good question, and one that does not seem to have been discussed on
>> the IronPython dev list, though there is outstanding work item on it:
>> http://ironpython.codeplex.com/workitem/21412. The only other reference I
>> can find is in the cmodule.py IronPython unit test script:
>>
>> "#Modules we don't implement found in DLLs or Lib and
>> #the reason why:
>> # bz2 - TODO?"
>>
>> Just a guess: the only OSS C# bzip2 library that I could find is licensed
>> under GPL2, which conflicts with IronPython's MS-PL license, and nobody has
>> felt like re-implementing it.
>>
>> In addition, there is a project called IronClad which allows you to load
>> CPython's bz2.pyd. Unfortunately, IronClad is not yet available for
>> IronPython 2.7 and hg flat out cannot run on IronPython 2.6, which lacks
>> some very basic built-in modules (e.g. signal). Moreover, IronClad's
>> developer list has gone quiet as of late, so I'm not anticipating any new
>> development soon.
>>
>> An ipy bz2 implementation is probably just low priority given that
>> IronPython is now community driven. The main contributors are turning their
>> attention to 3.0 support.
>>
>> That's all just conjecture, though.
>
> A simple Google search pointed me to http://www.digistar.com/bzip2/,
> which seems like it might be helpful.
Certainly plain-old-C is instructive as an example implementation.
However, we would be looking for a C# implementation (or CLS-compliant
.NET library) to use for implementing bz2 in IronPython.
I've sent a email to the guys at ICSharpCode to seek clarification of
the licensing terms for their .NET-based bzip2 library (or consider a
separate license for the IronLanguages project). That would be a big
step forward for getting bz2 support into ipy 2.7+.
>
>>
>>
>> On 5/9/2011 10:52 AM, Augie Fackler wrote:
>>>
>>> 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