EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

problem with python-ctypes on embedded systems

Started by Unknown October 27, 2013
Hi,

I tried to add pyusb to buildroot ( http://lists.busybox.net/pipermail/buildroot/2013-October/081200.html ) and run into problems with ctypes not loading the appropriate libusb backend ( http://lists.busybox.net/pipermail/buildroot/2013-October/081219.html ).

The problem is associated with the way how ctypes package detects the name of necessary shared library. Particularly it fails on uclibc based systems running on Arm platform. 
I'm interested if someone has also faced that problem, and found a good solution.
I had to patch the nested  _findSoname_ldconfig(name) function in the  Python-2.7.3/Lib/ctypes/util.py file, adding the appropriate definition for my platform:

            mach_map = {
                'x86_64-64': 'libc6,x86-64',
                'ppc64-64': 'libc6,64bit',
                'sparc64-64': 'libc6,64bit',
                's390x-64': 'libc6,64bit',
                'ia64-64': 'libc6,IA-64',
                'armv6l','libc0', # Added by WZab for ctypes support on Raspberry Pi
                }
            abi_type = mach_map.get(machine, 'libc6')

but this approach doesn't seem to be satissfactory...

-- 
Regards,
Wojtek
On Sunday, October 27, 2013 4:11:48 PM UTC-4, wza...@gmail.com wrote:
> 'armv6l','libc0', # Added by WZab for ctypes support on
Wojtek - did you mean to put a colon ":" instead of the first comma "," above ?
W dniu poniedziałek, 28 października 2013 14:06:03 UTC+1 użytkownik Dave Nadler napisał:
> On Sunday, October 27, 2013 4:11:48 PM UTC-4, wza...@gmail.com wrote: > > > 'armv6l','libc0', # Added by WZab for ctypes support on > > > > Wojtek - did you mean to put a colon ":" instead of the first comma "," above ?
Yes, of course. My mistake. But anyway the problem exists. This mistype would only break my workaround... Thanks, Wojtek
Well, in fact my mistake was even worse, to get it working one must
add the "-32" or "-64" suffix to the name of the platform.

So the correct content of mach_map is:

           mach_map = {
                'x86_64-64': 'libc6,x86-64',
                'ppc64-64': 'libc6,64bit',
                'sparc64-64': 'libc6,64bit',
                's390x-64': 'libc6,64bit',
                'ia64-64': 'libc6,IA-64',
                'armv6l-32':'libc0', # Added by WZab for ctypes support
                }
            abi_type = mach_map.get(machine, 'libc6')

Sorry for confusion. My fault.
I have tested that setting of abi_type to 'libc0' does the trick, and then sent the workaround supposed to substitute it only for my platform, without testing it :-(.
-- 
Regards,
Wojtek
My GPG/PGP keys:
8192R/4569D119 - for standard messages
16384R/1312D8F8 - for confidential messages

The 2024 Embedded Online Conference