[C++-sig] [Py++] Generate Python code for ctypes?

Nikolaus Rath Nikolaus at rath.org
Mon Dec 14 00:55:28 CET 2009


Roman Yakovenko <roman.yakovenko at gmail.com> writes:
>> The generated code contains
>>
>> libfuse_lib = ctypes.CDLL( r"/usr/lib/libfuse.so" )
>>
>> I'd rather have the library looked up dynamically, as in
>>
>> libfuse = CDLL(find_library("fuse"))
>>
>> Is there a way to accomplish this?
>
> The functionality you ask doesn't exist right now. If I remember
> right, ctypes module has "look for a library" functionality. I will
> take a look how to integrate it with Py++.
>
> Your ideas ( and patches ) are welcome.

I looked into the code a bit. It seems that for the symbols file, it is
not possible to get rid of the absolute path, because it is passed to an
external command (and the output of ctypes.find_library is only useful to
ctypes.CDLL).

For the shared_lib file, however, it seems alright to always use
CDLL(find_library()) instead of CDLL with an absolute path.

I tried to create a patch, but when I tried to find out where the
'CDLL(...)' code is actually written, I got completely lost in the
source...


What I don't quite understand is what the symbols file is actually used
for. The code seems to determine the symbols available in the shared
library, but what is it doing with that information? Certainly all the
exported symbols should already be available from parsing the header
file... Is it possible to omit the symbols file and generate code based
only on the headers?


Best,


   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C



More information about the Cplusplus-sig mailing list