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