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

Zachary Gramana zgramana at pottsconsultinggroup.com
Mon May 9 09:01:45 CDT 2011


# 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.

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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Mercurial_14198.patch
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110509/b4d3d1eb/attachment.txt>


More information about the Mercurial-devel mailing list