1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 pythonOlder,
8 mpv,
9 setuptools,
10}:
11
12buildPythonPackage rec {
13 pname = "mpv";
14 version = "1.0.7";
15 format = "pyproject";
16
17 src = fetchFromGitHub {
18 owner = "jaseg";
19 repo = "python-mpv";
20 rev = "v${version}";
21 hash = "sha256-2sYWTzj7+ozezNX0uFdJW+A0K6bwAmiVvqo/lr9UToA=";
22 };
23
24 patches = [
25 # https://github.com/jellyfin/jellyfin-mpv-shim/issues/448
26 (fetchpatch {
27 url = "https://github.com/jaseg/python-mpv/commit/12850b34bd3b64704f8abd30341a647a73719267.patch";
28 hash = "sha256-2O7w8PeWinCzrigGX3IV+9PVCtU9KCM2UJ32Y1kE6m0=";
29 })
30 ];
31
32 disabled = pythonOlder "3.9";
33
34 nativeBuildInputs = [ setuptools ];
35
36 buildInputs = [ mpv ];
37
38 postPatch = ''
39 substituteInPlace mpv.py \
40 --replace-fail "sofile = ctypes.util.find_library('mpv')" \
41 'sofile = "${mpv}/lib/libmpv${stdenv.hostPlatform.extensions.sharedLibrary}"'
42 '';
43
44 pythonImportsCheck = [ "mpv" ];
45
46 meta = with lib; {
47 description = "Python interface to the mpv media player";
48 homepage = "https://github.com/jaseg/python-mpv";
49 license = licenses.agpl3Plus;
50 maintainers = with maintainers; [ onny ];
51 };
52}