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