ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> distutils-sig
distutils-sig
[Distutils] Looking for portable what to determine directory where extensions are installed?
by Tom Epperly other posts by this author
Nov 6 2009 12:55PM messages near this date
Re: [Distutils] People want CPAN :-) | [Distutils] 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

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@[...].org
http://mail.python.org/mailman/listinfo/distutils-sig
Thread:
Tom Epperly
Tom Epperly
Toshio Kuratomi
Tres Seaver

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved