GNU bug report logs - #44275
[PATCH] gnu: Add python-pydub.

Previous Next

Package: guix-patches;

Reported by: Tanguy Le Carrour <tanguy <at> bioneland.org>

Date: Wed, 28 Oct 2020 08:58:01 UTC

Severity: normal

Tags: patch

Done: Leo Famulari <leo <at> famulari.name>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44275 in the body.
You can then email your comments to 44275 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Wed, 28 Oct 2020 08:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tanguy Le Carrour <tanguy <at> bioneland.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 28 Oct 2020 08:58:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tanguy Le Carrour <tanguy <at> bioneland.org>
To: guix-patches <at> gnu.org
Cc: Tanguy Le Carrour <tanguy <at> bioneland.org>
Subject: [PATCH] gnu: Add python-pydub.
Date: Wed, 28 Oct 2020 09:56:54 +0100
* gnu/packages/python-xyz.scm (python-pydub): New variable.
---
 gnu/packages/python-xyz.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 6c5ccac647..55580a251b 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -16659,6 +16659,28 @@ ignoring formatting changes.")
 (define-public python2-pydiff
   (package-with-python2 python-pydiff))
 
+(define-public python-pydub
+  (package
+    (name "python-pydub")
+    (version "0.24.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pydub" version))
+       (sha256
+        (base32
+         "0sfwfq7yjv4bl3yqbmizszscafvwf4zr40hzbsy7rclvzyznh333"))))
+    (build-system python-build-system)
+    (home-page "http://pydub.com")
+    (propagated-inputs
+     `(("ffmpeg" ,ffmpeg)
+       ("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
+@code{ffmpeg} to open various audio formats.")
+    (license license:expat))) ; MIT license
+
 (define-public python-tqdm
   (package
     (name "python-tqdm")
-- 
2.29.1





Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Wed, 28 Oct 2020 16:35:02 GMT) Full text and rfc822 format available.

Message #8 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Tanguy Le Carrour <tanguy <at> bioneland.org>
Cc: 44275 <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Wed, 28 Oct 2020 12:34:50 -0400
On Wed, Oct 28, 2020 at 09:56:54AM +0100, Tanguy Le Carrour wrote:
> * gnu/packages/python-xyz.scm (python-pydub): New variable.

> +    (propagated-inputs
> +     `(("ffmpeg" ,ffmpeg)
> +       ("python-scipy" ,python-scipy)))

It would be good if store references to these programs could be "baked in" to
the pydub code, rather than propagated. Can you take a look at how they
are called and see if that is feasible? Often there is only one location
that must be patched.




Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Thu, 29 Oct 2020 08:28:01 GMT) Full text and rfc822 format available.

Message #11 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Tanguy Le Carrour <tanguy <at> bioneland.org>
To: Leo Famulari <leo <at> famulari.name>
Cc: 44275 <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Thu, 29 Oct 2020 09:26:57 +0100
Hi Leo,

Thanks for taking the time to review this!

Le 10/28, Leo Famulari a écrit :
> On Wed, Oct 28, 2020 at 09:56:54AM +0100, Tanguy Le Carrour wrote:
> > * gnu/packages/python-xyz.scm (python-pydub): New variable.
> 
> > +    (propagated-inputs
> > +     `(("ffmpeg" ,ffmpeg)
> > +       ("python-scipy" ,python-scipy)))
> 
> It would be good if store references to these programs could be "baked in" to
> the pydub code, rather than propagated. Can you take a look at how they
> are called and see if that is feasible? Often there is only one location
> that must be patched.

mmm… haven't done that so far, it would be my first time! Always good to
learn new tricks! :-)
I'll try to patch the call to `ffmpeg` and let you know.

`python-scipy` is a different problem, though. This module is not listed
as a requirement, but… it's required at run time. Event if I don't see the
point of having SciPy loaded when you want to manipulate audio. But that's
a different matter!

Regards,

-- 
Tanguy




Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Thu, 29 Oct 2020 09:10:02 GMT) Full text and rfc822 format available.

Message #14 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Tanguy Le Carrour <tanguy <at> bioneland.org>
To: 44275 <at> debbugs.gnu.org
Cc: Tanguy Le Carrour <tanguy <at> bioneland.org>, leo <at> famulari.name
Subject: [PATCH v2] gnu: Add python-pydub.
Date: Thu, 29 Oct 2020 10:09:29 +0100
* gnu/packages/python-xyz.scm (python-pydub): New variable.
---
 gnu/packages/python-xyz.scm | 38 +++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 9f689d35b5..e938081d28 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -16683,6 +16683,44 @@ ignoring formatting changes.")
 (define-public python2-pydiff
   (package-with-python2 python-pydiff))
 
+(define-public python-pydub
+  (package
+    (name "python-pydub")
+    (version "0.24.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pydub" version))
+       (sha256
+        (base32
+         "0sfwfq7yjv4bl3yqbmizszscafvwf4zr40hzbsy7rclvzyznh333"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-ffmpeg-path
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((ffmpeg (assoc-ref inputs "ffmpeg")))
+               (substitute* '("pydub/utils.py")
+                 (("return \"ffmpeg\"")
+                  (string-append "return \"" ffmpeg "/bin/ffmpeg\""))
+                 (("return \"ffplay\"")
+                  (string-append "return \"" ffmpeg "/bin/ffplay\""))
+                 (("return \"ffprobe\"")
+                  (string-append "return \"" ffmpeg "/bin/ffprobe\""))
+                 (("warn\\(\"Couldn't find ff") "# warn\\(\"Couldn't find ff"))
+               #t))))))
+    (home-page "http://pydub.com")
+    (inputs
+     `(("ffmpeg" ,ffmpeg)))
+    (propagated-inputs
+     `(("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
+@code{ffmpeg} to open various audio formats.")
+    (license license:expat))) ; MIT license
+
 (define-public python-tqdm
   (package
     (name "python-tqdm")
-- 
2.29.1





Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Thu, 29 Oct 2020 14:15:01 GMT) Full text and rfc822 format available.

Message #17 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Tanguy Le Carrour <tanguy <at> bioneland.org>
Cc: 44275 <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Thu, 29 Oct 2020 10:14:27 -0400
On Thu, Oct 29, 2020 at 09:26:57AM +0100, Tanguy Le Carrour wrote:
> Hi Leo,
> 
> Thanks for taking the time to review this!
> 
> Le 10/28, Leo Famulari a écrit :
> > On Wed, Oct 28, 2020 at 09:56:54AM +0100, Tanguy Le Carrour wrote:
> > > * gnu/packages/python-xyz.scm (python-pydub): New variable.
> > 
> > > +    (propagated-inputs
> > > +     `(("ffmpeg" ,ffmpeg)
> > > +       ("python-scipy" ,python-scipy)))
> > 
> > It would be good if store references to these programs could be "baked in" to
> > the pydub code, rather than propagated. Can you take a look at how they
> > are called and see if that is feasible? Often there is only one location
> > that must be patched.
> 
> mmm… haven't done that so far, it would be my first time! Always good to
> learn new tricks! :-)
> I'll try to patch the call to `ffmpeg` and let you know.
> 
> `python-scipy` is a different problem, though. This module is not listed
> as a requirement, but… it's required at run time. Event if I don't see the
> point of having SciPy loaded when you want to manipulate audio. But that's
> a different matter!

Okay, I will take a look at the scipy thing today.




Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Thu, 29 Oct 2020 14:40:02 GMT) Full text and rfc822 format available.

Message #20 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Tanguy Le Carrour <tanguy <at> bioneland.org>
To: Leo Famulari <leo <at> famulari.name>
Cc: 44275 <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Thu, 29 Oct 2020 15:39:08 +0100
Le 10/29, Leo Famulari a écrit :
> On Thu, Oct 29, 2020 at 09:26:57AM +0100, Tanguy Le Carrour wrote:
> > […]
> > > It would be good if store references to these programs could be "baked in" to
> > > the pydub code, rather than propagated. Can you take a look at how they
> > > are called and see if that is feasible? Often there is only one location
> > > that must be patched.
> > […]
> > `python-scipy` is a different problem, though. This module is not listed
> > as a requirement, but… it's required at run time. Event if I don't see the
> > point of having SciPy loaded when you want to manipulate audio. But that's
> > a different matter!
> 
> Okay, I will take a look at the scipy thing today.

Great, thanks!

If it was up to me, I would remove altogether everything that is
related to `scipy`, meaning the `pydub/scipy_effects.py` file. But it
wouldn't be the same software any more, would it? ^_^'

Regards,

-- 
Tanguy




Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Thu, 29 Oct 2020 21:52:02 GMT) Full text and rfc822 format available.

Message #23 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Tanguy Le Carrour <tanguy <at> bioneland.org>
Cc: 44275 <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Thu, 29 Oct 2020 17:50:53 -0400
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Fri, 30 Oct 2020 09:20:02 GMT) Full text and rfc822 format available.

Message #26 received at 44275 <at> debbugs.gnu.org (full text, mbox):

From: Tanguy Le Carrour <tanguy <at> bioneland.org>
To: Leo Famulari <leo <at> famulari.name>
Cc: 44275 <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Fri, 30 Oct 2020 10:19:01 +0100
Hi Leo!


Le 10/29, Leo Famulari a écrit :
> 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.

+1…

> 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

So I guess you didn't see the one I submitted: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44275#14 :-(
I was really proud, because… it worked! :-)

But yours is shorter and does the job (even if it "brute-force" replaces all
the occurences of "ffmpeg", even in the comments!) and I'm totally fine
with it!

Thanks again for your help and your time!

-- 
Tanguy




Reply sent to Leo Famulari <leo <at> famulari.name>:
You have taken responsibility. (Fri, 30 Oct 2020 20:41:01 GMT) Full text and rfc822 format available.

Notification sent to Tanguy Le Carrour <tanguy <at> bioneland.org>:
bug acknowledged by developer. (Fri, 30 Oct 2020 20:41:01 GMT) Full text and rfc822 format available.

Message #31 received at 44275-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Tanguy Le Carrour <tanguy <at> bioneland.org>
Cc: 44275-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] gnu: Add python-pydub.
Date: Fri, 30 Oct 2020 16:40:47 -0400
[Message part 1 (text/plain, inline)]
On Thu, Oct 29, 2020 at 10:09:29AM +0100, Tanguy Le Carrour wrote:
> * gnu/packages/python-xyz.scm (python-pydub): New variable.

Thanks! Pushed as 96767739a1d2222ed802dd5dcfa2bda1df85df77

> +         (add-after 'unpack 'fix-ffmpeg-path
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (let ((ffmpeg (assoc-ref inputs "ffmpeg")))
> +               (substitute* '("pydub/utils.py")
> +                 (("return \"ffmpeg\"")
> +                  (string-append "return \"" ffmpeg "/bin/ffmpeg\""))
> +                 (("return \"ffplay\"")
> +                  (string-append "return \"" ffmpeg "/bin/ffplay\""))
> +                 (("return \"ffprobe\"")
> +                  (string-append "return \"" ffmpeg "/bin/ffprobe\""))
> +                 (("warn\\(\"Couldn't find ff") "# warn\\(\"Couldn't find ff"))
> +               #t))))))

This solution is more correct than the one I suggested. Thanks!

> +    (home-page "http://pydub.com")

I made this use HTTPS.

> +    (synopsis "Manipulate audio with an simple and easy high level interface")
> +    (description
> +     "@code{pydub} makes it easy to manipulate audio.  It relies on
> +@code{ffmpeg} to open various audio formats.")

And I tweaked these to avoid so-called "marketing language" and to
clarify that pydub is in Python, which I think can be useful when
searching for packages.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Fri, 30 Oct 2020 20:43:02 GMT) Full text and rfc822 format available.

Message #34 received at 44275-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Tanguy Le Carrour <tanguy <at> bioneland.org>
Cc: 44275-done <at> debbugs.gnu.org
Subject: Re: [bug#44275] [PATCH] gnu: Add python-pydub.
Date: Fri, 30 Oct 2020 16:42:17 -0400
On Fri, Oct 30, 2020 at 10:19:01AM +0100, Tanguy Le Carrour wrote:
> So I guess you didn't see the one I submitted: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44275#14 :-(

Oops! I missed your v2 patch by mistake.

> I was really proud, because… it worked! :-)

And it's better than my solution!




Information forwarded to guix-patches <at> gnu.org:
bug#44275; Package guix-patches. (Fri, 30 Oct 2020 21:11:02 GMT) Full text and rfc822 format available.

Message #37 received at 44275-done <at> debbugs.gnu.org (full text, mbox):

From: Tanguy LE CARROUR <tanguy <at> bioneland.org>
To: Leo Famulari <leo <at> famulari.name>
Cc: 44275-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] gnu: Add python-pydub.
Date: Fri, 30 Oct 2020 22:10:12 +0100
Hi,

Le 30 octobre 2020 21:40:47 CET, Leo Famulari <leo <at> famulari.name> a écrit :
>On Thu, Oct 29, 2020 at 10:09:29AM +0100, Tanguy Le Carrour wrote:
>> * gnu/packages/python-xyz.scm (python-pydub): New variable.
>
>Thanks! Pushed as 96767739a1d2222ed802dd5dcfa2bda1df85df77
>
>> +         (add-after 'unpack 'fix-ffmpeg-path
>> +           (lambda* (#:key inputs #:allow-other-keys)
>> +             (let ((ffmpeg (assoc-ref inputs "ffmpeg")))
>> +               (substitute* '("pydub/utils.py")
>> +                 (("return \"ffmpeg\"")
>> +                  (string-append "return \"" ffmpeg
>"/bin/ffmpeg\""))
>> +                 (("return \"ffplay\"")
>> +                  (string-append "return \"" ffmpeg
>"/bin/ffplay\""))
>> +                 (("return \"ffprobe\"")
>> +                  (string-append "return \"" ffmpeg
>"/bin/ffprobe\""))
>> +                 (("warn\\(\"Couldn't find ff") "# warn\\(\"Couldn't
>find ff"))
>> +               #t))))))
>
>This solution is more correct than the one I suggested. Thanks!
>
>> +    (home-page "http://pydub.com")
>
>I made this use HTTPS.
>
>> +    (synopsis "Manipulate audio with an simple and easy high level
>interface")
>> +    (description
>> +     "@code{pydub} makes it easy to manipulate audio.  It relies on
>> +@code{ffmpeg} to open various audio formats.")
>
>And I tweaked these to avoid so-called "marketing language" and to
>clarify that pydub is in Python, which I think can be useful when
>searching for packages.

Thanks!

-- 
Tanguy




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 28 Nov 2020 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 246 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.