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