Log in

No account? Create an account

hacking setuptools to compile pyrex modules on OS X

« previous entry | next entry »
Jul. 8th, 2008 | 03:22 pm

I was trying to install rdflib 2.4 on an OS X 10.5 machine and got the error message

  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/build_ext.py", line 77, in swig_sources
    sources = _build_ext.swig_sources(self, sources) or sources
TypeError: swig_sources() takes exactly 3 arguments (2 given)

Most of the first google hits weren't so useful, so here's my fix. There's also the possibility of upgrading setuptools, but that might break the OS X specific things that apple did to it. (Or you could always install a parallel version of python, but that's just icky).

/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/setuptools/command/build_ext.py line 77

--- command/build_ext.py	2008-07-08 15:04:34.000000000 -0700
+++ /tmp/build_ext.py	2008-07-08 15:04:24.000000000 -0700
@@ -73,9 +73,9 @@
     if _build_ext is not _du_build_ext:
         # Workaround for problems using some Pyrex versions w/SWIG and/or 2.4
         def swig_sources(self, sources, *otherargs):
             # first do any Pyrex processing
-            sources = _build_ext.swig_sources(self, sources) or sources
+            sources = _build_ext.swig_sources(self, sources, *otherargs) or sources
             # Then do any actual SWIG stuff on the remainder
             return _du_build_ext.swig_sources(self, sources, *otherargs)

As far as I can tell, the third parameter is "extensions" used by swig_sources at python2.5/distutils/command/build_ext.py line 516.

It's only used occasionally and looks to be a way of adding additional command line arguments when running swig on line 561

I have no idea if *otherargs actually contains an object of the right type, but at least I was able to build the package with the pyrex extension in it.
Tags: ,

Link | Leave a comment |

Comments {0}