Kirk suggested that the issue was that the GC wasn't being initialized, and after some searching I discovered the cause of that: Dynamic libraries on OS X >= 10.4 don't run the _init and _fini methods by default, but require you to annotate methods that should be run at load time.

Apparently compiling with "-framework Python" is not foolproof though, and I started to get this error instead:
"Fatal Python error: Interpreter not initialized (version mismatch?)"

The work around for this is to call a version of python that is binary compatible with the framework that your Pyd code linked against. How to figure that out? Run this:

Code:

minami:d markluffel$ otool -L testdll.so
testdll.so:
testdll.so (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
/Users/markluffel/dmdgcc/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.1)

and find the line that includes "Python.framework" and then use the python from that installation, for example "/Library/Frameworks/Python.framework/Versions/2.5/bin/python".