summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/python-ffmpeg/default.nix
blob: 0641ab386b5fec07e567b98b601caa8c030761f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  ffmpeg-headless,
  setuptools,
  pyee,
  pytestCheckHook,
  pytest-asyncio,
}:

buildPythonPackage rec {
  pname = "python-ffmpeg";
  version = "2.0.12";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "jonghwanhyeon";
    repo = "python-ffmpeg";
    tag = "v${version}";
    hash = "sha256-1dhkjrg7QUtYSyEV9c88HphdcFuSCSaGJqVAQmMF/5E=";
  };

  postPatch = ''
    substituteInPlace ffmpeg/{ffmpeg.py,asyncio/ffmpeg.py,protocol.py} \
      --replace-fail 'executable: str = "ffmpeg"' 'executable: str = "${lib.getExe ffmpeg-headless}"'
    substituteInPlace tests/helpers.py \
      --replace-fail '"ffprobe"' '"${lib.getExe' ffmpeg-headless "ffprobe"}"'

    # Some systems can finish before the `0.1` timeout.
    substituteInPlace tests/test_{,asyncio_}timeout.py \
      --replace-fail 'ffmpeg.execute(timeout=0.1)' 'ffmpeg.execute(timeout=0.01)'
  '';

  build-system = [ setuptools ];

  dependencies = [ pyee ];

  nativeCheckInputs = [
    pytestCheckHook
    pytest-asyncio
  ];

  pythonImportsCheck = [ "ffmpeg" ];

  meta = {
    homepage = "https://github.com/jonghwanhyeon/python-ffmpeg";
    description = "Python binding for FFmpeg which provides sync and async APIs";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ youhaveme9 ];
  };
}