Skip to contentSkip to conversation

pygrug breaks build with python2.2

PATCH Muli Ben-Yehuda 3 participants 5 messages Oct 19, 2005 – Oct 20, 2005

lore
Share & tools
lore
#0 lore raw

pygrub's setup.py relies on distutils.UnixCCompiler.has_function(), which does not exist with python2.2, causing the following build error:

make[2]: Entering directory `/home/muli/xen/x86.hg/tools/pygrub' CFLAGS=" -m32 -march=i686" python setup.py build Traceback (most recent call last):
File "setup.py", line 15, in ?

    if cc.has_function("ext2fs_open2"):

AttributeError: UnixCCompiler instance has no attribute 'has_function'

The following patch gets it to build, but is pretty ugly. A proper fix would be to do the check for ext2fs_open2() in a way that is backward compatible with python2.2.

Exporting patch:
# HG changeset patch
# User Muli Ben-Yehuda <[email protected]>
# Node ID 174450b627fd5aadc686d7737e23eb1a6a8a4175 # Parent 7c951e3eb5ab4ab0a6de33a8f831c828d16b1ad4 get pygrub to build with python2.2

tools/pygrub/setup.py +8 -5
diff -r 7c951e3eb5ab4ab0a6de33a8f831c828d16b1ad4 -r 174450b627fd5aadc686d7737e23eb1a6a8a4175 tools/pygrub/setup.py
@@ -12,11 +12,14 @@
     ext2defines = []
     cc = new_compiler()
     cc.add_library("ext2fs")
-    if cc.has_function("ext2fs_open2"):
-        ext2defines.append( ("HAVE_EXT2FS_OPEN2", None) )
-    else:
-        sys.stderr.write("WARNING: older version of e2fsprogs installed, not building full\n")
-        sys.stderr.write("         disk support for ext2.\n")
+    try:
+        if cc.has_function("ext2fs_open2"):
+            ext2defines.append( ("HAVE_EXT2FS_OPEN2", None) )
+        else:
+            sys.stderr.write("WARNING: older version of e2fsprogs installed, not building full\n")
+            sys.stderr.write("         disk support for ext2.\n")
+    except AttributeError:
+        pass
         
     ext2 = Extension("grub.fsys.ext2._pyext2",
                      extra_compile_args = extra_compile_args,
Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/
#1 lore raw

Hi,

Quoted 3 lines · Muli Ben-Yehuda

pygrub's setup.py relies on distutils.UnixCCompiler.has_function(), which does not exist with python2.2, causing the following build error:

[...]

Quoted 3 lines

The following patch gets it to build, but is pretty ugly. A proper fix would be to do the check for ext2fs_open2() in a way that is backward compatible with python2.2.

Why not just disable building pygrub if your python is that ancient?

Signature · 3 lines
Kurt Garloff                   <[email protected]>             [Koeln, DE]
Physics:Plasma modeling <[email protected]> [TU Eindhoven, NL]
Linux: SUSE Labs (Director)    <[email protected]>            [Novell Inc]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 6 lines · Kurt Garloff

Hi,

Quoted 3 lines · Muli Ben-Yehuda

pygrub's setup.py relies on distutils.UnixCCompiler.has_function(), which does not exist with python2.2, causing the following build error:

Quoted 6 lines

[...]

Quoted 3 lines

The following patch gets it to build, but is pretty ugly. A proper fix would be to do the check for ext2fs_open2() in a way that is backward compatible with python2.2.

Why not just disable building pygrub if your python is that ancient?

If this is the only thing required for it to work with 2.2, it would be a shame not to support it. If it's entirely dependant on 2.4, disabling it is fine. FWIW, the top-level README gives python2.2 as a prerequisite and everything else appears to build fine with it.

Cheers,
Muli

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/
#3 lore raw
In reply to Muli Ben-Yehuda
Quoted 3 lines · Muli Ben-Yehuda

pygrub's setup.py relies on distutils.UnixCCompiler.has_function(), which does not exist with python2.2, causing the following build error:

*sigh* And there doesn't seem to be a good way to do the functionality with older distutils. I guess if you're running that old of a python, it's probably fair to think that the version of e2fsprogs is old as well. Something like the following is a little bit cleaner, though.

Jeremy

tools/pygrub/setup.py +1 -1
diff -r 7c951e3eb5ab tools/pygrub/setup.py
@@ -12,7 +12,7 @@
     ext2defines = []
     cc = new_compiler()
     cc.add_library("ext2fs")
-    if cc.has_function("ext2fs_open2"):
+    if hasattr(cc, "has_function") and cc.has_function("ext2fs_open2"):
         ext2defines.append( ("HAVE_EXT2FS_OPEN2", None) )
     else:
         sys.stderr.write("WARNING: older version of e2fsprogs installed, not building full\n")

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 4 lines · Jeremy Katz

*sigh* And there doesn't seem to be a good way to do the functionality with older distutils. I guess if you're running that old of a python, it's probably fair to think that the version of e2fsprogs is old as well. Something like the following is a little bit cleaner, though.

Yup, I was looking for something like hasattr() but my python-fu was weak. Thanks!

Cheers,
Muli

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/