Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Looking for portable what to determine directory where extensions are installed?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


tepperly at llnl

Nov 5, 2009, 9:20 AM

Post #1 of 2 (38 views)
Permalink
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
--
http://mail.python.org/mailman/listinfo/python-list


gagsl-py2 at yahoo

Nov 5, 2009, 3:11 PM

Post #2 of 2 (32 views)
Permalink
Re: Looking for portable what to determine directory where extensions are installed? [In reply to]

En Thu, 05 Nov 2009 14:20:28 -0300, Tom Epperly <tepperly[at]llnl.gov>
escribió:

> 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

The distutils SIG is probably a better place to ask:
http://www.python.org/community/sigs/current/distutils-sig/

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.