1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cython,
6 fetchFromGitHub,
7 fetchurl,
8 linkFarm,
9 ffmpeg-headless,
10 numpy,
11 pillow,
12 pkg-config,
13 pytestCheckHook,
14 pythonOlder,
15 setuptools,
16}:
17
18buildPythonPackage rec {
19 pname = "av";
20 version = "14.1.0";
21 pyproject = true;
22
23 disabled = pythonOlder "3.9";
24
25 src = fetchFromGitHub {
26 owner = "PyAV-Org";
27 repo = "PyAV";
28 tag = "v${version}";
29 hash = "sha256-GYdt6KMMmDSyby447MbShL2GbrH8R1UuOeiVlztGuS4=";
30 };
31
32 build-system = [
33 cython
34 setuptools
35 ];
36
37 nativeBuildInputs = [ pkg-config ];
38
39 buildInputs = [ ffmpeg-headless ];
40
41 preCheck =
42 let
43 # Update with `./update-test-samples.bash` if necessary.
44 testSamples = linkFarm "pyav-test-samples" (
45 lib.mapAttrs (_: fetchurl) (lib.importTOML ./test-samples.toml)
46 );
47 in
48 ''
49 # ensure we import the built version
50 rm -r av
51 ln -s ${testSamples} tests/assets
52 '';
53
54 nativeCheckInputs = [
55 numpy
56 pillow
57 pytestCheckHook
58 ];
59
60 # `__darwinAllowLocalNetworking` doesn’t work for these; not sure why.
61 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
62 "tests/test_timeout.py"
63 ];
64
65 pythonImportsCheck = [
66 "av"
67 "av.audio"
68 "av.buffer"
69 "av.bytesource"
70 "av.codec"
71 "av.container"
72 "av._core"
73 "av.datasets"
74 "av.descriptor"
75 "av.dictionary"
76 "av.error"
77 "av.filter"
78 "av.format"
79 "av.frame"
80 "av.logging"
81 "av.option"
82 "av.packet"
83 "av.plane"
84 "av.stream"
85 "av.subtitles"
86 "av.utils"
87 "av.video"
88 ];
89
90 meta = with lib; {
91 description = "Pythonic bindings for FFmpeg";
92 mainProgram = "pyav";
93 homepage = "https://github.com/PyAV-Org/PyAV";
94 changelog = "https://github.com/PyAV-Org/PyAV/blob/v${version}/CHANGELOG.rst";
95 license = licenses.bsd2;
96 maintainers = [ ];
97 };
98}