[python-win32] Communicating symbols between extension modules

Jens B. Jorgensen jens.jorgensen at tallan.com
Tue Jan 13 17:03:49 EST 2004


Jack Jansen wrote:

>
> On 13-jan-04, at 18:30, Jens B. Jorgensen wrote:
>
>>> Right. But my problem is that I need to call *C* code from that 
>>> other module: that code that I want to call is specifically meant to 
>>> wrap/unwrap C objects from their corresponding Python objects....
>>
>>
>> So why not just call LoadLibrary/GetProcAddress on the other DLL?
>
>
> This sounds like an interesting solution. Just to double-check: I have 
> two Python extension modules _Qt.pyd and _Cm.pyd and the first one 
> needs the routine CmpObj_Convert from the latter one I can 
> LoadLibrary(_Cm.pyd) and it will work both when _Cm.pyd has already 
> been loaded through the normal import mechanism and when it hasn't, 
> and a subsequent import will also work correctly?

Though I haven't tried it I cannot think of a reason why not. The only 
scenario I could think of where things could go astray is if you called 
LoadLibrary(_Cm.pyd) and then called a function in it which relied on 
the python module stuff in _Cm.pyd being initialized if it had not been. 
Even then though you could get around this by just asking Python to 
import the module before you LoadLibrary it yourself.

> That leaves one question: can I get at the filename from where _Qt.pyd 
> has been loaded? Because I would need that to construct the pathname 
> for _Cm.pyd.

I imagine that it is part of some internal struct that you could get a 
hold of. Well, let me just go and check. Well indeed in moduleobject.h I 
see:

PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *);

and I would be surprised if this is not function in question.

-- 
Jens B. Jorgensen
jens.jorgensen at tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions."

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3108 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mail.python.org/pipermail/python-win32/attachments/20040113/fa4ba079/smime.bin


More information about the Python-win32 mailing list