From b639c57aaa83688ce09fa0c2ba1a51e6089884bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Fri, 30 Apr 2021 12:23:29 +0200 Subject: [PATCH] python3Packages.imageio-ffmpeg: 0.4.2 -> 0.4.3 Also hardcode path to ffmpeg executable. Can be overridden using $IMAGEIO_FFMPEG_EXE. --- .../python-modules/imageio-ffmpeg/default.nix | 45 ++++++++++++------- .../imageio-ffmpeg/ffmpeg-path.patch | 39 ++++++++++++++++ 2 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 pkgs/development/python-modules/imageio-ffmpeg/ffmpeg-path.patch diff --git a/pkgs/development/python-modules/imageio-ffmpeg/default.nix b/pkgs/development/python-modules/imageio-ffmpeg/default.nix index db59ba70bb2..bb186d6594c 100644 --- a/pkgs/development/python-modules/imageio-ffmpeg/default.nix +++ b/pkgs/development/python-modules/imageio-ffmpeg/default.nix @@ -1,29 +1,42 @@ { lib , buildPythonPackage -, fetchPypi -, fetchpatch , isPy3k +, fetchPypi +, substituteAll +, ffmpeg +, python }: buildPythonPackage rec { pname = "imageio-ffmpeg"; - version = "0.4.2"; - - src = fetchPypi { - inherit pname version; - sha256 = "13b05b17a941a9f4a90b16910b1ffac159448cff051a153da8ba4b4343ffa195"; - }; - patches = [ (fetchpatch { - # Fixes compatibility with python3.9 - # Should be included in the next release after 0.4.2 - url = "https://github.com/imageio/imageio-ffmpeg/pull/43/commits/b90c39fe3d29418d67d953588ed9fdf4d848f811.patch"; - sha256 = "0d9kf4w6ldwag3s2dr9zjin6wrj66fnl4fn8379ci4q4qfsqgx3f"; - })]; + version = "0.4.3"; disabled = !isPy3k; - # No test infrastructure in repository. - doCheck = false; + src = fetchPypi { + inherit pname version; + sha256 = "f826260a3207b872f1a4ba87ec0c8e02c00afba4fd03348a59049bdd8215841e"; + }; + + patches = [ + (substituteAll { + src = ./ffmpeg-path.patch; + ffmpeg = "${ffmpeg}/bin/ffmpeg"; + }) + ]; + + checkPhase = '' + runHook preCheck + + ${python.interpreter} << EOF + from imageio_ffmpeg import get_ffmpeg_version + assert get_ffmpeg_version() == '${ffmpeg.version}' + EOF + + runHook postCheck + ''; + + pythonImportsCheck = [ "imageio_ffmpeg" ]; meta = with lib; { description = "FFMPEG wrapper for Python"; diff --git a/pkgs/development/python-modules/imageio-ffmpeg/ffmpeg-path.patch b/pkgs/development/python-modules/imageio-ffmpeg/ffmpeg-path.patch new file mode 100644 index 00000000000..d193ec199f9 --- /dev/null +++ b/pkgs/development/python-modules/imageio-ffmpeg/ffmpeg-path.patch @@ -0,0 +1,39 @@ +diff --git a/imageio_ffmpeg/_utils.py b/imageio_ffmpeg/_utils.py +index 1399cfd..c0eb9be 100644 +--- a/imageio_ffmpeg/_utils.py ++++ b/imageio_ffmpeg/_utils.py +@@ -23,33 +23,7 @@ def get_ffmpeg_exe(): + if exe: + return exe + +- plat = get_platform() +- +- # 2. Try from here +- bin_dir = resource_filename("imageio_ffmpeg", "binaries") +- exe = os.path.join(bin_dir, FNAME_PER_PLATFORM.get(plat, "")) +- if exe and os.path.isfile(exe) and _is_valid_exe(exe): +- return exe +- +- # 3. Try binary from conda package +- # (installed e.g. via `conda install ffmpeg -c conda-forge`) +- if plat.startswith("win"): +- exe = os.path.join(sys.prefix, "Library", "bin", "ffmpeg.exe") +- else: +- exe = os.path.join(sys.prefix, "bin", "ffmpeg") +- if exe and os.path.isfile(exe) and _is_valid_exe(exe): +- return exe +- +- # 4. Try system ffmpeg command +- exe = "ffmpeg" +- if _is_valid_exe(exe): +- return exe +- +- # Nothing was found +- raise RuntimeError( +- "No ffmpeg exe could be found. Install ffmpeg on your system, " +- "or set the IMAGEIO_FFMPEG_EXE environment variable." +- ) ++ return '@ffmpeg@' + + + def _popen_kwargs(prevent_sigint=False):