Python/D API

Kirk McDonald kirklin.mcdonald at gmail.com
Thu May 25 16:01:25 PDT 2006


David Rushby wrote:
> In article <e52igv$2pd$1 at digitaldaemon.com>, Kirk McDonald says...
> 
>>There are numerous references in a Google search to Deja Augustine's 
>>port of the Python/C API headers to D, but the site 
>>(http://www.scratch-ware.net/dfiles/) is down, and apparently has been 
>>for a while.
>>...
>>The header (I quickly discovered) is for version 2.3 of Python, where 
>>the current version is 2.4.
> 
> 
> Deja Augustine's version is outdated and also limited in its coverage of the
> Python API.  Try this:
> http://kinterbasdb.sourceforge.net/other/d/celerid-2006_03_19.zip
> 
> That zip includes a trivial example.  It worked fine with Python 2.4.x and the
> then-current version of D last time I tried it (which was March 19, 2006).
> 
> However, it doesn't work at all on non-Windows platforms because [the Digital
> Mars implementation of] D only supports dynamic linking on Windows.  That fact
> alone prevents me from using D for anything useful.


That's a really nice package. I've been spending the past day or so 
looking through it. ("Celerid"? Where does that name come from?) It is a 
pity about DMD not doing dynamic linking outside of Windows, though your 
header is still useful for embedding Python in a D program on a Linux 
system:

[test.d]
import python;

int main() {
     Py_Initialize();
     PyRun_SimpleString("print 'Hello world!'\n");
     Py_Finalize();
     return 0;
}

$ dmd test -L-lpython2.4
gcc test.o -o test -lphobos -lpthread -lm -Xlinker -lpython2.4
$ ./test
Hello, world!

Or, for that matter, on Windows.

-Kirk McDonald



More information about the Digitalmars-d mailing list