rpath alike feature for python scripts

Olaf Hering olaf at aepfle.de
Fri Jul 25 10:08:13 EDT 2014


Hello,

ELF binaries have a concept of RPATH, that means the interpreter looks
for libraries first in a list of directories provided by the binary
before falling back to default system directories.

Since python scripts also do some sort of library loading, but lack an
RPATH like feature, I'm asking here how to simulate it.

The specific case I'm trying to address is the pygrub script which is
included in the xen-tools package. This script makes use of other python
libs provided by xen-tools. 

If xen is configured with --prefix=/some/where the python libs will be
installed (in my case) in "/some/where/lib64/python2.6/site-packages".
However, there seems to be no way in advance to know that exact
location. If it would be known at build time, then something could
tweak the pygrub script and insert the searchpath below "/some/where".

And is this the right approach anyway?

+sys.path.insert(0, "/some/where/lib64/python2.6/site-packages")

After browsing the disutils documentation its not clear if setup.py has
a way to help with this.

Here is a pointer to a discussion I started a while ago, and the sources:
http://lists.xenproject.org/archives/html/xen-devel/2014-04/msg02931.html
http://xenbits.xen.org/gitweb/?p=xen.git;a=tree;f=tools/pygrub
http://xenbits.xen.org/gitweb/?p=xen.git;a=tree;f=tools/python


Thanks for any pointers.

Olaf



More information about the Python-list mailing list