summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/gst-python/default.nix
blob: fc182732af4241052d57f324530be8c22a80e85a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchurl,
  fetchpatch,
  meson,
  ninja,
  # TODO: We can get rid of this once `buildPythonPackage` accepts `finalAttrs`.
  # See: https://github.com/NixOS/nixpkgs/pull/271387
  gst-python,

  pkg-config,
  python,
  pygobject3,
  gobject-introspection,
  gst_all_1,
  isPy3k,
  directoryListingUpdater,
}:

buildPythonPackage rec {
  pname = "gst-python";
  version = "1.26.0";

  pyproject = false;

  outputs = [
    "out"
    "dev"
  ];

  src = fetchurl {
    url = "https://gstreamer.freedesktop.org/src/gst-python/gst-python-${version}.tar.xz";
    hash = "sha256-5QRqBdd6uxVnGtAc0ZCNF9YuWgb114Qb5DQq3io/uNs=";
  };

  patches = [
    # Fix segfault with PyGObject>=3.52.0
    # https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8653
    (fetchpatch {
      url = "https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/69bba61e548c7a63bc18137e63e41489a7de9d36.patch";
      stripLen = 2;
      hash = "sha256-BfWPc8dsB09KiEm9bNT8e+jH76jiDefQlEhhLJoq7tI=";
    })

    # https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4322
    ./skip-failing-test-not-initialized.patch
  ];

  # Python 2.x is not supported.
  disabled = !isPy3k;

  depsBuildBuild = [ pkg-config ];

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    gobject-introspection
    gst_all_1.gst-plugins-base
  ];

  buildInputs = [
    # for gstreamer-analytics-1.0
    gst_all_1.gst-plugins-bad
  ];

  propagatedBuildInputs = [
    gst_all_1.gst-plugins-base
    pygobject3
  ];

  checkInputs = [
    gst_all_1.gst-rtsp-server
  ];

  mesonFlags = [
    "-Dpygi-overrides-dir=${placeholder "out"}/${python.sitePackages}/gi/overrides"
    # Exec format error during configure
    "-Dpython-exe=${python.pythonOnBuildForHost.interpreter}"
    # This is needed to prevent the project from looking for `gst-rtsp-server`
    # from `checkInputs`.
    #
    # TODO: This should probably be moved at least partially into the Meson hook.
    #
    # NB: We need to use `doInstallCheck` here because `buildPythonPackage`
    # renames `doCheck` to `doInstallCheck`.
    (lib.mesonEnable "tests" gst-python.doInstallCheck)
  ];

  # `buildPythonPackage` uses `installCheckPhase` and leaves `checkPhase`
  # empty. It renames `doCheck` from its arguments, but not `checkPhase`.
  # See: https://github.com/NixOS/nixpkgs/issues/47390
  installCheckPhase = ''
    runHook preCheck
    mesonCheckPhase
    runHook postCheck
  '';

  preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
    export DYLD_LIBRARY_PATH="${gst_all_1.gst-plugins-base}/lib"
  '';

  passthru = {
    updateScript = directoryListingUpdater { };
  };

  meta = {
    homepage = "https://gstreamer.freedesktop.org";
    description = "Python bindings for GStreamer";
    license = lib.licenses.lgpl2Plus;
    maintainers = [ ];
  };
}