gnome.nautilus-python: fix loading gi

This commit is contained in:
Jan Tojnar 2021-10-25 07:30:11 +02:00
parent 34ad3ffe08
commit 6767e0ed8e
2 changed files with 27 additions and 1 deletions

View file

@ -1,4 +1,6 @@
{ lib, stdenv { stdenv
, lib
, substituteAll
, fetchurl , fetchurl
, pkg-config , pkg-config
, which , which
@ -23,6 +25,16 @@ stdenv.mkDerivation rec {
sha256 = "161050sx3sdxqcpjkjcpf6wl4kx0jydihga7mcvrj9c2f8ly0g07"; sha256 = "161050sx3sdxqcpjkjcpf6wl4kx0jydihga7mcvrj9c2f8ly0g07";
}; };
patches = [
# Make PyGObjects gi library available.
(substituteAll {
src = ./fix-paths.patch;
pythonPaths = lib.concatMapStringsSep ", " (pkg: "'${pkg}/${python3.sitePackages}'") [
python3.pkgs.pygobject3
];
})
];
nativeBuildInputs = [ nativeBuildInputs = [
pkg-config pkg-config
which which

View file

@ -0,0 +1,14 @@
diff --git a/src/nautilus-python.c b/src/nautilus-python.c
index 843e3c6..466a513 100644
--- a/src/nautilus-python.c
+++ b/src/nautilus-python.c
@@ -184,6 +184,9 @@ nautilus_python_init_python (void) {
return FALSE;
}
+ debug("Add PyGObject to path");
+ PyRun_SimpleString("import site;import functools; functools.reduce(lambda k, p: site.addsitedir(p, k), [@pythonPaths@], site._init_pathinfo())");
+
/* import gobject */
debug("init_pygobject");
if (!np_init_pygobject()) {