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