Auto locate Python's .so on Linux (for cx_Freeze's --shared-lib-name)

robert no-spam at not-existing.invalid
Sun Nov 18 17:22:47 EST 2007


James Stroud wrote:
> robert wrote:
>> In a makefile I want to locate the .so for a dynamically linked Python 
>> on Linux. (for cx_Freeze's --shared-lib-name)
>> e.g. by running a small script with that Python. How to?
>>
>> Robert
> 
> def findaso(aso):
>   import os
>   for apath in os.sys.path:
>     if not apath.startswith(os.path.sep):
>       apath = os.path.join(os.path.curdir, apath)
>     try:
>       files = os.listdir(apath)
>     except OSError:
>       pass
>     if aso in files:
>       return apath
> 
> 
> py> def findaso(aso):
> ...   import os
> ...   for apath in os.sys.path:
> ...     if not apath.startswith(os.path.sep):
> ...       apath = os.path.join(os.path.curdir, apath)
> ...     try:
> ...       files = os.listdir(apath)
> ...     except OSError:
> ...       pass
> ...     if aso in files:
> ...       return apath
> ...
> py> findaso('_tkinter.so')
> '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload' 
> 
> 
> James
> 


I'd need to know already the name and oon this installation it is 
for example /usr/lib/libpython2.4.so.1.0

/usr/lib is not in sys.path


Robert





More information about the Python-list mailing list