1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonOlder,
7 uv-build,
8 pytestCheckHook,
9 go,
10 ffmpeg-headless,
11}:
12
13buildPythonPackage rec {
14 pname = "ffmpy";
15 version = "0.6.1";
16 pyproject = true;
17
18 disabled = pythonOlder "3.8.1";
19
20 src = fetchFromGitHub {
21 owner = "Ch00k";
22 repo = "ffmpy";
23 tag = version;
24 hash = "sha256-u//L2vxucFlWmk1+pdp+iCrpzzMZUonDAn1LELgX86E=";
25 };
26
27 postPatch =
28 # Default to store ffmpeg.
29 ''
30 substituteInPlace ffmpy/ffmpy.py \
31 --replace-fail \
32 'executable: str = "ffmpeg",' \
33 'executable: str = "${lib.getExe ffmpeg-headless}",'
34 ''
35 # The tests test a mock that does not behave like ffmpeg. If we default to the nix-store ffmpeg they fail.
36 + ''
37 for fname in tests/*.py; do
38 echo >>"$fname" 'FFmpeg.__init__.__defaults__ = ("ffmpeg", *FFmpeg.__init__.__defaults__[1:])'
39 done
40 '';
41
42 pythonImportsCheck = [ "ffmpy" ];
43
44 build-system = [ uv-build ];
45
46 nativeCheckInputs = [
47 pytestCheckHook
48 go
49 ];
50
51 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
52 # expects a FFExecutableNotFoundError, gets a NotADirectoryError raised by os
53 "test_invalid_executable_path"
54 ];
55
56 # the vendored ffmpeg mock binary assumes FHS
57 preCheck = ''
58 rm -v tests/ffmpeg/ffmpeg
59 echo Building tests/ffmpeg/ffmpeg...
60 HOME=$(mktemp -d) go build -o tests/ffmpeg/ffmpeg tests/ffmpeg/ffmpeg.go
61 '';
62
63 meta = with lib; {
64 description = "Simple python interface for FFmpeg/FFprobe";
65 homepage = "https://github.com/Ch00k/ffmpy";
66 license = licenses.mit;
67 maintainers = with maintainers; [ pbsds ];
68 };
69}