[pygtk] nixos _gtk.so not found
Marc Weber
marco-oweber at gmx.de
Mon Nov 24 19:01:42 WST 2008
Hi,
I'm trying to package pygtk for NixOS.
NixOS is special in the regard that each pacakge is put into its own
directory.
To make this work I've patched site.py to also addsitedir all packages
found in NIX_PYTHON_SITES [1] which seems to work fine.
I can compile and install pygtk212 and I even can run this code
import pygtk; pygtk.require('2.0')
import gtk
without error, but only from the build directory.
running
$ echo -e "import pygtk; pygtk.require('2.0')\nimport gtk" | python
from somewhere else results in
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ImportError: No module named gtk
The problem is that _gtk.so is installed but can't be found later on.
I've seen that there is kind of import helper called ltihooks.py which
adds '.libs' sometimes somewhere in a hook(?). But that file is not
installed by default.
Do you know about an easy way to tell python about that new location?
Isn't addsitedir enough to make it work?
python version is 2.5 (I've also tried 2.6)
What would you try to make it work?
Sincerly
Marc Weber
[1]
--- Python-2.5-orig/Lib/site.py 2008-05-10 19:36:24.000000000 +0200
+++ Python-2.5/Lib/site.py 2008-11-17 05:37:02.000000000 +0100
@@ -390,6 +390,20 @@
except ImportError:
pass
+def addnixsitepackages(known_paths):
+ """
+ used to add multiple site packages for /nix/store to sys.path also
+ evaluating the .pth files (http://docs.python.org/library/site.html#module-site)
+ """
+ env_nix_sites = os.environ.get("NIX_PYTHON_SITES", None)
+ if env_nix_sites:
+ for path in env_nix_sites.split(":"):
+ if os.path.isdir(path):
+ NIX_SITE = os.path.join(path, "lib",
+ "python" + sys.version[:3],
+ "site-packages")
+ addsitedir(NIX_SITE, known_paths)
+ return known_paths
def main():
abs__file__()
@@ -400,6 +414,7 @@
paths_in_sys = addsitepackages(paths_in_sys)
if sys.platform == 'os2emx':
setBEGINLIBPATH()
+ paths_in_sys = addnixsitepackages(paths_in_sys)
setquit()
setcopyright()
sethelper()
More information about the pygtk
mailing list