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

R

robert

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
 
J

James Stroud

robert said:
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

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com
 
N

Neal Becker

robert said:
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

How about run python -v yourscript and filter the output?
 
R

robert

James said:
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
 
R

robert

Neal said:
How about run python -v yourscript and filter the output?

for examples here python -v delivers many other python module
paths, but not Python's .so. For example

/usr/lib/libpython2.4.so.1.0



Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top