Looking for portable what to determine directory where extensions are installed?
I work on a language interoperability tool, Babel https://computation.llnl.gov/casc/components/components.html; and I need a portable way to determine the directory where Python extension modules are installed by distutils (i.e., lib or lib64) to resolve this issue: https://www.cca-forum.org/bugs/babel/issue670 For example, I will invoke "python setup.py install --prefix=/home/foo/_inst --exec-prefix=/home/foo/_inst", and it usually installs the extensions in either /home/foo/_inst/lib/python2.5/site-packages or /home/foo/_inst/lib64/python2.5/site-packages. Initially, I did the following to determine where the extensions actually got installed: # assume exec_prefix=/home/foo/_inst # assume python_version=`python -c 'import sys; print sys.version' | sed '1s/^\(...\).*/\1/g;1q'` RUNTIME_PYTHON="$exec_prefix/lib/python$python_verbose/site-packages" This worked fine until I started running on 64-bit Python machines where the correct result was RUNTIME_PYTHON="$exec_prefix/lib64/python$python_verbose/site-packages" The first 64-bit machine I was using seemed to have this patch: http://bugs.python.org/file14726/Python-2.6.2-multilib.patch, so I amended my script to the following: pylib=`$PYTHON -c "import sys; print sys.__dict__.get('lib','lib')"` RUNTIME_PYTHON="$exec_prefix/$pylib/python$python_version/site-packages" However, this approach doesn't work with Fedora Core 12 prerelease or some other 64-bit Linux distributions. They don't define "sys.lib". I thought distutils.sysconfig.get_python_lib() might be helpful, but it returns "/usr/lib/python2.6/site-packages" even on the system where "/usr/lib64/python2.6/site-packages" is the right answer. Is there a canonical, Pythonic way to determine whether an installation of Python uses "lib" or "lib64"? Or is there a way to determine the full path of where distutils will install extensions relative to the specified exec prefix? Regards, Tom Epperly
participants (1)
-
Tom Epperly