Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Looking for portable what to determine directory where extensionsare installed?

Reply
Thread Tools

Looking for portable what to determine directory where extensionsare installed?

 
 
Tom Epperly
Guest
Posts: n/a
 
      11-05-2009
I work on a language interoperability tool, Babel
https://computation.llnl.gov/casc/co...mponents.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/Pyt...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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
Portable Python - free portable development environment ! perica.zivkovic@gmail.com Python 7 01-13-2007 11:19 AM
portable (VHDL) vs. non-portable (altera LPM) approaches to signed computations Eli Bendersky VHDL 1 03-01-2006 02:43 PM
Portable way of obtaining current working directory...... Shaun Heveron C++ 6 10-28-2004 12:06 AM
nuby: determine method passed and determine the receiver that received the method Peņa, Botp Ruby 1 01-24-2004 07:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57