Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 pythonOlder, 7 uv-build, 8 pytestCheckHook, 9 go, 10 ffmpeg-headless, 11}: 12 13buildPythonPackage rec { 14 pname = "ffmpy"; 15 version = "0.6.0"; 16 pyproject = true; 17 18 disabled = pythonOlder "3.8.1"; 19 20 src = fetchFromGitHub { 21 owner = "Ch00k"; 22 repo = "ffmpy"; 23 tag = version; 24 hash = "sha256-U20mBg+428kkka6NY9qc7X8jH8A5bKa++g2+PTn/MYg="; 25 }; 26 27 postPatch = 28 # Default to store ffmpeg. 29 '' 30 substituteInPlace ffmpy/ffmpy.py \ 31 --replace-fail \ 32 'executable: str = "ffmpeg",' \ 33 'executable: str = "${lib.getExe ffmpeg-headless}",' 34 '' 35 # The tests test a mock that does not behave like ffmpeg. If we default to the nix-store ffmpeg they fail. 36 + '' 37 for fname in tests/*.py; do 38 echo >>"$fname" 'FFmpeg.__init__.__defaults__ = ("ffmpeg", *FFmpeg.__init__.__defaults__[1:])' 39 done 40 '' 41 # uv-build in nixpkgs is now at 0.8.0, which otherwise breaks the constraint set by the package. 42 + '' 43 substituteInPlace pyproject.toml \ 44 --replace-fail 'requires = ["uv_build>=0.7.9,<0.8.0"]' 'requires = ["uv_build>=0.7.9,<0.9.0"]' 45 ''; 46 47 pythonImportsCheck = [ "ffmpy" ]; 48 49 build-system = [ uv-build ]; 50 51 nativeCheckInputs = [ 52 pytestCheckHook 53 go 54 ]; 55 56 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ 57 # expects a FFExecutableNotFoundError, gets a NotADirectoryError raised by os 58 "test_invalid_executable_path" 59 ]; 60 61 # the vendored ffmpeg mock binary assumes FHS 62 preCheck = '' 63 rm -v tests/ffmpeg/ffmpeg 64 echo Building tests/ffmpeg/ffmpeg... 65 HOME=$(mktemp -d) go build -o tests/ffmpeg/ffmpeg tests/ffmpeg/ffmpeg.go 66 ''; 67 68 meta = with lib; { 69 description = "Simple python interface for FFmpeg/FFprobe"; 70 homepage = "https://github.com/Ch00k/ffmpy"; 71 license = licenses.mit; 72 maintainers = with maintainers; [ pbsds ]; 73 }; 74}