1{ buildPythonPackage, fetchurl, meson, ninja, stdenv, pkgconfig, python, pygobject3
2, gobject-introspection, gst-plugins-base, isPy3k
3}:
4
5let
6 pname = "gst-python";
7 version = "1.14.4";
8 name = "${pname}-${version}";
9in buildPythonPackage rec {
10 inherit pname version;
11 format = "other";
12
13 outputs = [ "out" "dev" ];
14
15 src = fetchurl {
16 urls = [
17 "${meta.homepage}/src/gst-python/${name}.tar.xz"
18 "mirror://gentoo/distfiles/${name}.tar.xz"
19 ];
20 sha256 = "06ssx19fs6pg4d32p9ph9w4f0xwmxaw2dxfj17rqkn5njd7v5zfh";
21 };
22
23 patches = [
24 # Meson build does not support Python 2 at the moment
25 # https://bugzilla.gnome.org/show_bug.cgi?id=796092
26 (fetchurl {
27 name = "0002-meson-use-new-python-module.patch";
28 url = https://bugzilla.gnome.org/attachment.cgi?id=371989;
29 sha256 = "1k46nvw175c1wvkqnx783i9d4w9vn431spcl48jb3y224jj3va08";
30 })
31 # Fixes `from gi.repository import Gst` when gst-python's site-package is in
32 # PYTHONPATH
33 (fetchurl {
34 url = https://gitlab.freedesktop.org/gstreamer/gst-python/commit/d64bbc1e0c3c948c148f505cc5f856ce56732880.diff;
35 sha256 = "1n9pxmcl1x491mp47avpcw2a6n71lm0haz6mfas168prkgsk8q3r";
36 })
37 # Fixes python2 build from the above changes
38 (fetchurl {
39 url = https://gitlab.freedesktop.org/gstreamer/gst-python/commit/f79ac2d1434d7ba9717f3e943cfdc76e121eb5dd.diff;
40 sha256 = "17a164b0v36g0kwiqdlkjx6g0pjhcs6ilizck7iky8bgjnmiypm1";
41 })
42 ];
43
44 # TODO: First python_dep in meson.build needs to be removed
45 postPatch = ''
46 substituteInPlace meson.build --replace python3 python${if isPy3k then "3" else "2"}
47 '';
48
49 nativeBuildInputs = [ meson ninja pkgconfig python gobject-introspection gst-plugins-base ];
50
51 mesonFlags = [
52 "-Dpython=python${if isPy3k then "3" else "2"}"
53 "-Dpygi-overrides-dir=${placeholder "out"}/${python.sitePackages}/gi/overrides"
54 ];
55
56 doCheck = true;
57
58 # TODO: Meson setup hook does not like buildPythonPackage
59 # https://github.com/NixOS/nixpkgs/issues/47390
60 installCheckPhase = "meson test --print-errorlogs";
61
62 propagatedBuildInputs = [ gst-plugins-base pygobject3 ];
63
64 meta = {
65 homepage = https://gstreamer.freedesktop.org;
66
67 description = "Python bindings for GStreamer";
68
69 license = stdenv.lib.licenses.lgpl2Plus;
70 };
71}