FAQ
Hello everyone,

I've got a ctypes wrapper to some code which seems to be different
when compiled on 32 bit linux compared to 64 bit linux. For the
windows version I can use sys.platform == 'win32' versus 'linux2' to
decide whether to get the .dll or .so library to load. Having narrowed
it down to linux I still need to choose between libKLT32.so and
libKLT64.so

Can someone tell me an idiom to choose the right one?

Thanks!

Jon

Search Discussions

  • Matt Nordhoff at Feb 12, 2008 at 7:54 am

    Jon wrote:
    Hello everyone,

    I've got a ctypes wrapper to some code which seems to be different
    when compiled on 32 bit linux compared to 64 bit linux. For the
    windows version I can use sys.platform == 'win32' versus 'linux2' to
    decide whether to get the .dll or .so library to load. Having narrowed
    it down to linux I still need to choose between libKLT32.so and
    libKLT64.so

    Can someone tell me an idiom to choose the right one?

    Thanks!

    Jon
    What about the platform module? platform.architecture() should do it.

    <http://docs.python.org/lib/module-platform.html>

    <http://docs.python.org/lib/node442.html#l2h-3157>
    import platform
    platform.architecture()
    ('32bit', '')

    Note that it analyzes an executable (defaulting to the python
    interpreter binary), rather than looking in /proc or something. You
    might want to do something like that instead. I guess looking at the
    python binary is more accurate on a hybrid 32-bit/64-bit system though..
    --
  • Christian Heimes at Feb 12, 2008 at 8:53 am

    Jon wrote:
    Can someone tell me an idiom to choose the right one?
    You can check the size of a void pointer with ctypes:
    import ctypes
    ctypes.sizeof(ctypes.c_void_p) * 8
    32

    Christian
  • Jon at Feb 12, 2008 at 9:23 am

    Christian Heimes wrote:
    You can check the size of a void pointer with ctypes:
    import ctypes
    ctypes.sizeof(ctypes.c_void_p) * 8
    And Matt Nordhoff wrote:
    import platform
    platform.architecture()
    Thanks guys! Exactly what I was after.

    -Jon

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 12, '08 at 7:23a
activeFeb 12, '08 at 9:23a
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase