Can't load .pyd files from embedded Python interp

edream at tds.net.bbs edream at tds.net.bbs
Mon Jul 17 12:40:01 EDT 2000


Gordon McMillan wrote:

> Most people just use python15.dll from their embedding app so both get the
> same copy. Using Borland probably adds some warts to the process, since
> everybody has to end up using the same c runtime. Your best bet is to look
> for some posts by Gordon Williams, who has instructions on building python
> with Borland.

Gordon, thanks so much for this reply.  This was precisely what I
needed.

There were several factors making it difficult for me to see the
obvious.

1.  I had no idea that python15.dll existed or that it was loaded as
part of the Windows install.  One of Gordon Williams posts on
comp.lang.python mentions that python15.dll is found in
C:\Windows\System

2.  I had previously abandoned the idea of using either python15.dll or
python15.lib with Borland C because some of the "very high level" C
API's use FILE * arguments, which obviously won't work with Borland C.
But the solution is trivial: just make sure that the code in the
embedding app never calls these functions!

3.  I had no idea that linking python15.dll, rather than python15.lib,
is required when embedding Python in an app.  It is required so that
imported .pyd files can access variables in the Python interpreter.

This illustrates one of the most common failings in documentation:
failing to tell _what_ the reader is to do and _why_.  Much
documentation just jumps in and explains _how_ to do something.  I just
reviewed the Python Extending and Embedding docs.  There is no mention
that one must link against python15.dll, and certainly no hint about
why that is necessary.  One or two sentences in the docs might have
saved me about a week of enjoyable, but useless, work.

I'll write up my experiences when I've successfully embedded Python in
my app.  For now the conclusion seems to be that one only need link in
C:\Windows\System\python15.dll to the app.  There are some details
specific to Borland, but presumably they won't be difficult.

Again, thanks so much for setting me on the right track.

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edream at tds.net
Leo: Literate Editor with Outlines
Leo: http://personalpages.tds.net/~edream/front.html
--------------------------------------------------------------------



More information about the Python-list mailing list