[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Compiling pygame on Ubuntu 11.10 oneiric JPGE not found
On 28.01.2012 21:52, Lenard Lindstrom wrote:
> config_unix.py checks what libraries are present to determine which
> Pygame modules are built. Otherwise, yes, the linker can find the
> libraries. The ldconfig program lists the shared libraries recognized by
> the run-time linker. So that could replace directory searches.
Here's some code to read the output of ldconfig. I have no idea though
how portable that is.
Chris
# -*- coding:utf-8 -*-
import re
import subprocess
ldrx = re.compile(r'^\s+(.*?)\s+\((.*?)\)\s+=>\s+(.*)$')
def read_ldcache():
"""Parse output of 'ldconfig -p' and return a dict with library file names
as keys and a tuple of (path, type) as values.
"""
output = subprocess.check_output(['/sbin/ldconfig', '--print-cache'],
env=dict(LC_ALL='C'))
ldcache = dict()
for line in output.splitlines()[1:]:
match = ldrx.match(line)
if match:
lib, type_, path = match.groups()
ldcache[lib] = (path, type_)
return ldcache
if __name__ == '__main__':
import pprint
pprint.pprint(read_ldcache())