Unverified Commit fcd67e5c authored by June Stepp's avatar June Stepp
Browse files

python3Packages.python-ffmpeg: give ffmpeg access, run tests

parent 2af6de63
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  ffmpeg-headless,
  setuptools,
  pyee,
  fetchPypi,
  setuptools-scm,
  pytestCheckHook,
  pytest-asyncio,
}:

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

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

  propagatedBuildInputs = [ pyee ];
  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
  ];

  nativeBuildInputs = [ setuptools-scm ];
  pythonImportsCheck = [ "ffmpeg" ];

  meta = {