[PATCH] gnu: Add python-pydub.

  • Done
  • quality assurance status badge
Details
2 participants
  • Leo Famulari
  • Tanguy Le Carrour
Owner
unassigned
Submitted by
Tanguy Le Carrour
Severity
normal
T
T
Tanguy Le Carrour wrote on 28 Oct 2020 09:56
(address . guix-patches@gnu.org)(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)
20201028085654.18295-1-tanguy@bioneland.org
* gnu/packages/python-xyz.scm (python-pydub): New variable.
---
gnu/packages/python-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (35 lines)
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
L
L
Leo Famulari wrote on 28 Oct 2020 17:34
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)(address . 44275@debbugs.gnu.org)
20201028163450.GE12095@jasmine.lan
On Wed, Oct 28, 2020 at 09:56:54AM +0100, Tanguy Le Carrour wrote:
Toggle quote (6 lines)
> * 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.
T
T
Tanguy Le Carrour wrote on 29 Oct 2020 09:26
(name . Leo Famulari)(address . leo@famulari.name)(address . 44275@debbugs.gnu.org)
20201029082657.xb3we5aqncp7qqci@rafflesia
Hi Leo,

Thanks for taking the time to review this!

Le 10/28, Leo Famulari a écrit :
Toggle quote (12 lines)
> 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
T
T
Tanguy Le Carrour wrote on 29 Oct 2020 10:09
[PATCH v2] gnu: Add python-pydub.
(address . 44275@debbugs.gnu.org)
20201029090929.10508-1-tanguy@bioneland.org
* gnu/packages/python-xyz.scm (python-pydub): New variable.
---
gnu/packages/python-xyz.scm | 38 +++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

Toggle diff (51 lines)
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
L
L
Leo Famulari wrote on 29 Oct 2020 15:14
Re: [bug#44275] [PATCH] gnu: Add python-pydub.
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)(address . 44275@debbugs.gnu.org)
20201029141427.GB8956@jasmine.lan
On Thu, Oct 29, 2020 at 09:26:57AM +0100, Tanguy Le Carrour wrote:
Toggle quote (26 lines)
> 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.
T
T
Tanguy Le Carrour wrote on 29 Oct 2020 15:39
(name . Leo Famulari)(address . leo@famulari.name)(address . 44275@debbugs.gnu.org)
20201029143908.ay6nvhik5brjws7g@rafflesia
Le 10/29, Leo Famulari a écrit :
Toggle quote (14 lines)
> 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
L
L
Leo Famulari wrote on 29 Oct 2020 22:50
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)(address . 44275@debbugs.gnu.org)
20201029215053.GA11109@jasmine.lan
On Thu, Oct 29, 2020 at 10:14:27AM -0400, Leo Famulari wrote:
Toggle quote (2 lines)
> 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.

Toggle diff (31 lines)
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
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAl+bOT0ACgkQJkb6MLrK
fwhA7A//XPKxPB8OjVk/RIK3LSWe8nrnOkimu1nEt1YalsluhH9P7WHiqRPEP3rZ
d4SjfWVGq/NlwFLPclIGZtY3ptKLM/L/ucqfDjK5MttyHOASJ3mdQxMkerH/tysz
aKmbGl+uCfBuC8wHlW9s+fdTeUzjelI2Fxumd0nIXxVTe+CELenrjTUxZY2gI+IH
D+BsxepRrIDfflJPn1rplM9BGpVGzLIT0FX9tsUW74UxmmCn6QhPTQbcbrEFDDF+
rIfU407h/AldsJlJPrjRGsqbT9K8UiZows8cU4BxisGFrHDxFOc7Jw/6tzg9XYPF
j+q2ZnrSQ9V5uZENrPDxsn4paa7HXfhm6RQ721gHxRIhO9Zef5ubAadZQ0L1GAwN
4fMb1pNLwPIJR2VtSboYTi50hN0UFjIkEgGSpoP6e6ZJT1JchSKX8v5/vjjebdyh
6ehtVlFEe969js1PMjp2a1YdH4tqp9JqOv4zREVW/Kio+G8+lsZNfLxTDQo5kjw9
sbkgkZTfsvZEkuTLEhN1+KRznD9c744A+6OWJWaBAOVI0s9mmu5y+u0JuKhj0G9V
c+KqmPLtcm1k1xtB8och39CB3VjUNxT5cpt2N+iNZpdbYX/RVHmScw7VvkKRMHoo
UvfecOZxGIYLDmzOE18FkePX9vIxMSfv2t+FoZX7es/jik5LEmE=
=SiXq
-----END PGP SIGNATURE-----


T
T
Tanguy Le Carrour wrote on 30 Oct 2020 10:19
(name . Leo Famulari)(address . leo@famulari.name)(address . 44275@debbugs.gnu.org)
20201030091901.3wktfpjmup64kflh@melmoth
Hi Leo!


Le 10/29, Leo Famulari a écrit :
Toggle quote (15 lines)
> 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…

Toggle quote (36 lines)
> 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
L
L
Leo Famulari wrote on 30 Oct 2020 21:40
Re: [PATCH v2] gnu: Add python-pydub.
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)(address . 44275-done@debbugs.gnu.org)
20201030204047.GA10794@jasmine.lan
On Thu, Oct 29, 2020 at 10:09:29AM +0100, Tanguy Le Carrour wrote:
Toggle quote (2 lines)
> * gnu/packages/python-xyz.scm (python-pydub): New variable.

Thanks! Pushed as 96767739a1d2222ed802dd5dcfa2bda1df85df77

Toggle quote (13 lines)
> + (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!

Toggle quote (2 lines)
> + (home-page "http://pydub.com")

I made this use HTTPS.

Toggle quote (5 lines)
> + (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.
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAl+cek8ACgkQJkb6MLrK
fwiMQw/5AV7OM2P/GXuHLo3DbNxCQYl1AEWOi10s0qEuaN2ftWRSGuDjN7h5hI26
SRXtT02SKMZ4eub09Ry9u0CMcu9LmHORp585bTPTbX+b4/i7pUCzMMweGqc5AgeP
ScDpot+o8nxdrCwbc0xqiXOjDr9+3fiYnk6tZjWHCIYyl0H1o+wV/IxziJboBZ4D
O9m+ie8221Up5sKxeTySth71YQ2Iw9FZbHXbBzG/FSe0F24iaHjQyMU7ra8t0LJQ
ixvnH49fVMCGX/47lvCL1O2rhm1rClp4CU4yzN0rcWgy/PhA8LgXM1uwXDnlFkXJ
igZImn3Hj5PwL9CTWvMQ22rlPMnCOo0kSOoaAZ3GfcZLhvQd6LU1YCCUqe42xZ8M
F574nguDEgxpS5c7PDjIR3TVXIuNmoA1vb9bUwQ5khd/YNNjiPhgn2rydmfOLAJl
BueSKhbLuVZiHENKE8LZX7MbE7qjE0VkWJUjZp/nAGwwUh2u2gYc7D2quNylZFe1
BxC443DRYC5DcmdwEU9EGIes04W7AzB5BMCNSXeC+F0TCvxZsEWreBAYVz/0LfD/
6QDAQ0Vi9HQ93ZyMs2ng0/k0GIGXCT1KO8fDVurY4WCshP4SZamicK6fS+GTdpTk
+9fZxEj4u4Iwf3k7PS9Ib+Fpq6o23OqevDmJqMvWYreIKXIdMhg=
=PHOd
-----END PGP SIGNATURE-----


Closed
L
L
Leo Famulari wrote on 30 Oct 2020 21:42
Re: [bug#44275] [PATCH] gnu: Add python-pydub.
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)(address . 44275-done@debbugs.gnu.org)
20201030204217.GA13279@jasmine.lan
On Fri, Oct 30, 2020 at 10:19:01AM +0100, Tanguy Le Carrour wrote:
Toggle quote (2 lines)
> 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.

Toggle quote (2 lines)
> I was really proud, because… it worked! :-)

And it's better than my solution!
Closed
T
T
Tanguy LE CARROUR wrote on 30 Oct 2020 22:10
Re: [PATCH v2] gnu: Add python-pydub.
(name . Leo Famulari)(address . leo@famulari.name)(address . 44275-done@debbugs.gnu.org)
2E87DEE0-ECF4-441F-B69D-51911ABDBD7C@bioneland.org
Hi,

Le 30 octobre 2020 21:40:47 CET, Leo Famulari <leo@famulari.name> a écrit :
Toggle quote (38 lines)
>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
Closed
?