1{ lib, stdenv, fetchurl, fetchpatch, python, pkg-config, gtk2, pygobject2, pycairo, pango
2, buildPythonPackage, isPy3k }:
3
4buildPythonPackage rec {
5 pname = "pygtk";
6 outputs = [ "out" "dev" ];
7 version = "2.24.0";
8 format = "other";
9
10 disabled = isPy3k;
11
12 src = fetchurl {
13 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.bz2";
14 sha256 = "04k942gn8vl95kwf0qskkv6npclfm31d78ljkrkgyqxxcni1w76d";
15 };
16
17 patches = [
18 # https://bugzilla.gnome.org/show_bug.cgi?id=660216 - fixes some memory leaks
19 (fetchpatch {
20 url = "https://gitlab.gnome.org/Archive/pygtk/commit/eca72baa5616fbe4dbebea43c7e5940847dc5ab8.diff";
21 sha256 = "031px4w5cshcx1sns430sdbr2i007b9zyb2carb3z65nzr77dpdd";
22 })
23 (fetchpatch {
24 url = "https://gitlab.gnome.org/Archive/pygtk/commit/4aaa48eb80c6802aec6d03e5695d2a0ff20e0fc2.patch";
25 sha256 = "0z8cg7nr3qki8gg8alasdzzyxcihfjlxn518glq5ajglk3q5pzsn";
26 })
27 ];
28
29 nativeBuildInputs = [ pkg-config ];
30 buildInputs = [
31 pango
32 ];
33
34 propagatedBuildInputs = [ gtk2 pygobject2 pycairo ];
35
36 configurePhase = "configurePhase";
37
38 buildPhase = "buildPhase";
39
40 NIX_CFLAGS_COMPILE = lib.optional stdenv.isDarwin "-ObjC"
41 ++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) "-lpython2.7";
42
43 installPhase = "installPhase";
44
45 checkPhase =
46 ''
47 sed -i -e "s/glade = importModule('gtk.glade', buildDir)//" \
48 tests/common.py
49 sed -i -e "s/, glade$//" \
50 -e "s/.*testGlade.*//" \
51 -e "s/.*(glade.*//" \
52 tests/test_api.py
53 '' + ''
54 sed -i -e "s/sys.path.insert(0, os.path.join(buildDir, 'gtk'))//" \
55 -e "s/sys.path.insert(0, buildDir)//" \
56 tests/common.py
57 make check
58 '';
59 # XXX: TypeError: Unsupported type: <class 'gtk._gtk.WindowType'>
60 # The check phase was not executed in the previous
61 # non-buildPythonPackage setup - not sure why not.
62 doCheck = false;
63
64 postInstall = ''
65 rm $out/bin/pygtk-codegen-2.0
66 ln -s ${pygobject2}/bin/pygobject-codegen-2.0 $out/bin/pygtk-codegen-2.0
67 ln -s ${pygobject2}/lib/${python.libPrefix}/site-packages/pygobject-${pygobject2.version}.pth \
68 $out/lib/${python.libPrefix}/site-packages/${pname}-${version}.pth
69 '';
70
71 meta = with lib; {
72 description = "GTK 2 Python bindings";
73 homepage = "https://gitlab.gnome.org/Archive/pygtk";
74 platforms = platforms.all;
75 license = with licenses; [ lgpl21Plus ];
76 };
77}