2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
pythonOlder,
|
|
|
|
setuptools,
|
|
|
|
pytestCheckHook,
|
|
|
|
go,
|
|
|
|
ffmpeg-headless,
|
2023-08-22 20:05:09 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "ffmpy";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "0.3.2";
|
|
|
|
pyproject = true;
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Ch00k";
|
|
|
|
repo = "ffmpy";
|
|
|
|
rev = "refs/tags/${version}";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-q41JjAWcIiD2nJck5Zzb/lhfIZ3xJGU1I2crsMN0T8Q=";
|
2023-08-22 20:05:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# default to store ffmpeg
|
|
|
|
substituteInPlace ffmpy.py \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace-fail 'executable="ffmpeg",' 'executable="${ffmpeg-headless}/bin/ffmpeg",'
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
# The tests test a mock that does not behave like ffmpeg. If we default to the nix-store ffmpeg they fail.
|
|
|
|
for fname in tests/*.py; do
|
|
|
|
echo 'FFmpeg.__init__.__defaults__ = ("ffmpeg", *FFmpeg.__init__.__defaults__[1:])' >>"$fname"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "ffmpy" ];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ setuptools ];
|
2024-02-29 20:09:43 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
go
|
|
|
|
];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
disabledTests = lib.optionals stdenv.isDarwin [
|
|
|
|
# expects a FFExecutableNotFoundError, gets a NotADirectoryError raised by os
|
|
|
|
"test_invalid_executable_path"
|
|
|
|
];
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
# the vendored ffmpeg mock binary assumes FHS
|
|
|
|
preCheck = ''
|
|
|
|
rm -v tests/ffmpeg/ffmpeg
|
|
|
|
HOME=$(mktemp -d) go build -o ffmpeg tests/ffmpeg/ffmpeg.go
|
|
|
|
export PATH=".:$PATH"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A simple python interface for FFmpeg/FFprobe";
|
|
|
|
homepage = "https://github.com/Ch00k/ffmpy";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ pbsds ];
|
|
|
|
};
|
|
|
|
}
|