[Pyrex] Pyrex on Mac OS X
Bob Ippolito
bob at redivi.com
Mon Nov 22 08:09:28 CET 2004
On Nov 22, 2004, at 7:19 AM, Justin Walker wrote:
> I am new to Python/Pyrex, and I use Mac OS X (10.3.6). I have some
> fairly simple code as a starting point for using Pyrex, and I'm not
> getting very far. I found a related discussion on the list about a
> year back in the archives, but I'm missing something.
>
> I have a small chunk of Python code that implements matrix
> multiplication, and an small chunk of Pyrex code that does the same.
> When I try to run the latter, I get this complaint:
>
> >>> prof.matmul()
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> File "/SandBox/sb/PyrexTest/PyHecke/prof.py", line 11, in matmul
> t1 = T1.timeit(tries)
> File
> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
> python2.3/timeit.py", line 158, in timeit
> return self.inner(it, self.timer)
> File "<timeit-src>", line 3, in inner
> ImportError: Inappropriate file type for dynamic loading
>
>
> This is the result of compiling the .c produced by pyrex on Mac OS X
> (I'm using WordTech's Eric, and MacPython):
>
> $ gcc -bundle -framework Python -O3 -fPIC mult2.c -c -o mult2.so \
>
> -I/System/Library/Frameworks/Python.framework//Versions/2.3/include/
> python2.3
> mult2.c:427: warning: initialization from incompatible pointer type
> gcc: -framework: linker input file unused because linking not done
> gcc: Python: linker input file unused because linking not done
>
> This code (both python and pyrex) works on Linux (Redhat 9.x).
>
> I can provide the code if it will shed light; I don't want to
> overwhelm the reader, right off.
You're not compiling it correctly. You shouldn't do such things by
hand, use distutils. I think in this case, the linker flags (-bundle
-framework Python) should have been towards the end. Also, -fPIC
shouldn't be necessary as it is the default unless you're using
-fast...
-bob
More information about the Pyrex
mailing list