Subject: [bug#44275] [PATCH] gnu: Add python-pydub.

From: Leo Famulari <[email-masked]>
Date: Thu, 29 Oct 2020 17:50:53 -0400

On Thu, Oct 29, 2020 at 10:14:27AM -0400, Leo Famulari wrote:
> Okay, I will take a look at the scipy thing today.

I decided to let scipy be propagated since it's normal for Python things
to be propagated. But I still think we should hard-code the reference to
ffmpeg.

I looked at the code, and it finds ffmpeg-related programs in
'pydub/utils.py', in the functions get_encoder_name(),
get_player_name(), and get_prober_name().

I think it should be sufficient to substitute any mention of the words
"ffmpeg", "ffplay", and "ffprobe" with the full store-path of those
programs.

I included a diff on your patch. You can see exactly what it does by
adding (error "Stopping...") after the substitute*, building with
--keep-failed, and then looking at the 'pydub/utils.py' file.

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 3c2d882003e..47ec542e6d1 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -16696,9 +16696,24 @@ ignoring formatting changes.")
          "0sfwfq7yjv4bl3yqbmizszscafvwf4zr40hzbsy7rclvzyznh333"))))
     (build-system python-build-system)
     (home-page "http://pydub.com")
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-ffmpeg-references
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((ffmpeg-store-item (assoc-ref inputs "ffmpeg"))
+                    (ffmpeg (string-append ffmpeg-store-item "/bin/ffmpeg"))
+                    (ffplay (string-append ffmpeg-store-item "/bin/ffplay"))
+                    (ffprobe (string-append ffmpeg-store-item "/bin/ffprobe")))
+               (substitute* "pydub/utils.py"
+                 (("ffmpeg") ffmpeg)
+                 (("ffplay") ffplay)
+                 (("ffprobe") ffprobe))
+               #t))))))
+    (inputs
+     `(("ffmpeg" ,ffmpeg)))
     (propagated-inputs
-     `(("ffmpeg" ,ffmpeg)
-       ("python-scipy" ,python-scipy)))
+     `(("python-scipy" ,python-scipy)))
     (synopsis "Manipulate audio with an simple and easy high level interface")
     (description
      "@code{pydub} makes it easy to manipulate audio.  It relies on