Skip to contentSkip to conversation

prefix and python site-packages

PATCH Olaf Hering 3 participants 7 messages Apr 23, 2014 – Apr 24, 2014

lore
Share & tools
lore
#0 lore raw

configure --prefix=/some/where puts pygrub and xen/lowlevel/xc.so below /some/where. But pygrub fails because it can not find the python site-packages. Is there a clean way to automate something like this?

tools/pygrub/src/pygrub +1 -0
index 7759b1a..4134082 100644
@@ -14,6 +14,7 @@
 #
 
 import os, sys, string, struct, tempfile, re, traceback
+sys.path.insert(0, "/some/where/lib64/python2.6/site-packages")
 import errno
 import copy
 import logging

Olaf

#1 lore raw
Quoted 3 lines · Olaf Hering

configure --prefix=/some/where puts pygrub and xen/lowlevel/xc.so below /some/where. But pygrub fails because it can not find the python site-packages. Is there a clean way to automate something like this?

Is this https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693721 ? I suppose not quite.

I think if you are installing to a non-standard prefix then you might expect to need to take manual action, like
editing /etc/python*/sitecustomize.py or setting $PYTHONPATH (this is analogous to editing /etc/ld.so.conf or setting $LD_LIBRARY_PATH I think).

I don't suppose python has an analogue of -rpath?

Ian.

#2 lore raw
Quoted 1 line · Ian Campbell

I don't suppose python has an analogue of -rpath?

Looks like sys.path.insert() is the python way of rpath. Would it be acceptable to tweak pygrub at install time and insert something like the hack I had posted earlier? From what I have seen pygrub is the only remaining binary using the xen.lowlevel stuff.

Olaf

#3 lore raw
Quoted 7 lines · Olaf Hering
Quoted 1 line · Ian Campbell

I don't suppose python has an analogue of -rpath?

Looks like sys.path.insert() is the python way of rpath. Would it be acceptable to tweak pygrub at install time and insert something like the hack I had posted earlier?

Does Python distutils (used by tools/pygrub/setup.py) not have any support for doing this sort of thing automatically?

Quoted 2 lines

From what I have seen
pygrub is the only remaining binary using the xen.lowlevel stuff.

It only uses it to decide if the hypervisor supports 64 bit PV guests. Since the we no longer have a 32-bit hypervisor perhaps we can just nuke that check and sidestep the whole problem?

Ian.

#4 lore raw
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Olaf Hering
Quoted 1 line · Ian Campbell

I don't suppose python has an analogue of -rpath?

Looks like sys.path.insert() is the python way of rpath. Would it be acceptable to tweak pygrub at install time and insert something like the hack I had posted earlier?

Does Python distutils (used by tools/pygrub/setup.py) not have any support for doing this sort of thing automatically?

I have to check.
But how would pygrub, or any other helloworld.py, know that it was installed into --prefix= and its libs/modules are also in --prefix=? I think something has to be hardcoded, unless PYTHONPATH or simimar is used to point to a specific --prefix=.

Quoted 6 lines
Quoted 2 lines

From what I have seen
pygrub is the only remaining binary using the xen.lowlevel stuff.

It only uses it to decide if the hypervisor supports 64 bit PV guests. Since the we no longer have a 32-bit hypervisor perhaps we can just nuke that check and sidestep the whole problem?

It also uses fsimage and grub.*, which is also installed below --prefix=

Olaf

#5 lore raw
Quoted 11 lines · Olaf Hering
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Olaf Hering
Quoted 1 line · Ian Campbell

I don't suppose python has an analogue of -rpath?

Looks like sys.path.insert() is the python way of rpath. Would it be acceptable to tweak pygrub at install time and insert something like the hack I had posted earlier?

Quoted 8 lines
Quoted 2 lines

Does Python distutils (used by tools/pygrub/setup.py) not have any support for doing this sort of thing automatically?

I have to check.
But how would pygrub, or any other helloworld.py, know that it was installed into --prefix= and its libs/modules are also in --prefix=? I think something has to be hardcoded, unless PYTHONPATH or simimar is used to point to a specific --prefix=.

setuyp.py is the thing which does all of this installing, so it knows where everything is going. It presumably also knows the default python path.

How does this work for every other python library/application out there? I can't imagine we are special here.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

From what I have seen
pygrub is the only remaining binary using the xen.lowlevel stuff.

It only uses it to decide if the hypervisor supports 64 bit PV guests. Since the we no longer have a 32-bit hypervisor perhaps we can just nuke that check and sidestep the whole problem?

It also uses fsimage and grub.*, which is also installed below --prefix=

OK, I only looked at xen.lowlevel since that was what you mentioned.

Ian.

#6 lore raw
In reply to Olaf Hering

Olaf Hering writes ("prefix and python site-packages"):

Quoted 3 lines

configure --prefix=/some/where puts pygrub and xen/lowlevel/xc.so below /some/where. But pygrub fails because it can not find the python site-packages. Is there a clean way to automate something like this?

I think normally --prefix should refer to somewhere where your python will look for packages.

If it doesn't, computing the correct path to use is going to be complicated I think.

Ian.