[PATCH] gnu: Add python-pysox.

  • Done
  • quality assurance status badge
Details
2 participants
  • Arun Isaac
  • jgart
Owner
unassigned
Submitted by
jgart
Severity
normal
J
J
J
jgart wrote on 8 Jul 2021 21:35
(address . 49469@debbugs.gnu.org)(name . jgart)(address . jgart@dismail.de)
20210708193555.4907-1-jgart@dismail.de
* gnu/packages/audio.scm (python-pysox): New variable.
---
gnu/packages/audio.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (43 lines)
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 3939d4bc7e..5222fb0343 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -2385,6 +2385,36 @@ compensation, (de)interleaving, and byte-swapping
;; original developer.
(license license:expat)))
+(define-public python-pysox
+ (package
+ (name "python-pysox")
+ (version "1.4.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "sox" version))
+ (sha256
+ (base32
+ "0m8hszh51lfzacbb4nxc5bn446c0dzljfqgnsff8h2s5j8vd3wmh"))))
+ (build-system python-build-system)
+ (arguments
+ ;; Tests require python-soundfile.
+ ;; TODO: enable tests once http://issues.guix.gnu.org/47181 is completed.
+ `(#:tests? #f))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)))
+ (native-inputs
+ `(("python-pytest" ,python-pytest)
+ ("python-pytest-cov" ,python-pytest-cov)))
+ (home-page "https://github.com/rabitt/pysox")
+ (synopsis "Python wrapper around sox")
+ (description "@code{pysox} is a wrapper around the @command{sox} command line tool.
+ pysox's API offers @code{Transformer} and @code{Combiner} classes that allow the user to
+incrementally build up effects and audio manipulations. @code{pysox} also
+provides methods for querying audio information such as sample rate,
+determining whether an audio file is silent and much more.")
+ (license license:bsd-3)))
+
(define-public python-pyaudio
(package
(name "python-pyaudio")
--
2.31.1
A
A
Arun Isaac wrote on 9 Oct 2021 17:20
(name . jgart)(address . jgart@dismail.de)(address . 49469@debbugs.gnu.org)
874k9qjkck.fsf@systemreboot.net
Hi jgart,

Toggle quote (4 lines)
> + ;; Tests require python-soundfile.
> + ;; TODO: enable tests once http://issues.guix.gnu.org/47181 is completed.
> + `(#:tests? #f))

python-soundfile is now in Guix. Could you try getting the tests
working?

Thank you!
Arun
-----BEGIN PGP SIGNATURE-----

iQFPBAEBCAA5FiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAmFhszsbHGFydW5pc2Fh
Y0BzeXN0ZW1yZWJvb3QubmV0AAoJEC4l7othgCuzc2AH/iD1Zhyqci7ddZ/xawKA
Uua5gvJ0fZY29/VN7N3BXZlEhXLsnyVsJ8z9p+AIKV1bAB0rOpUemCHoAncN7/v4
AZZZXlGzN3q25ogFDHEEPvvll/9dx0vUDbGXwo9tfOOLasRKMttH32ldabm3AjnN
q8YDcjWZi4Vlc9amtSy0xhBGw25x04+/IBO43ES/Tytz2GZyHXyGE7g4kEgBdrMY
oFP90REpYsLHpN9xcB8HXXXn3c6NkSI15vUz/vwzCjchxideaqWQZteNO4ZMBq3l
9GELMhVszmc1vg3BGYLbC4gQXUYyDYDKtLs3ecGzf64y2j5b+Rt6oXVVzqsLd+oR
uEQ=
=oUxN
-----END PGP SIGNATURE-----

J
(address . 49469@debbugs.gnu.org)
20211010061525.11302-1-jgart@dismail.de
Here is an updated patch. I got the tests to pass. I also realized that I had
to wrap some binaries.

all best,

jgart
J
(address . 49469@debbugs.gnu.org)(name . jgart)(address . jgart@dismail.de)
20211010061525.11302-2-jgart@dismail.de
* gnu/packages/audio.scm (python-pysox): New variable.
---
gnu/packages/audio.scm | 57 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)

Toggle diff (70 lines)
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index cc51ac51f3..8b412a63d1 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -2429,6 +2429,63 @@ compensation, (de)interleaving, and byte-swapping
;; original developer.
(license license:expat)))
+(define-public python-pysox
+ (let ((commit "3d0053381c24ae3490f759d4de87194b85789d36")
+ (revision "0"))
+ (package
+ (name "python-pysox")
+ (version (git-version "1.4.2" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/rabitt/pysox")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0i62jx92vfpcr2z7lp69yzqdi9idfs3pifl3rzm2akc2c4cr1mac"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-sox
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((sox-store-path (assoc-ref inputs "sox"))
+ (sox-bin (string-append sox-store-path "/bin/sox")))
+ (substitute* "sox/__init__.py"
+ (("sox -h")
+ (string-append sox-bin " -h")))
+ (substitute* "sox/core.py"
+ (("\\['sox")
+ (string-append "['" sox-bin)))
+ (substitute* "sox/log.py"
+ (("Logger\\('sox")
+ (string-append "Logger\('" sox-bin))))))
+ (replace 'check
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (setenv "PYTHONPATH" (string-append ".:" (getenv "PYTHONPATH")))
+ (invoke "pytest")))))))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-typing-extensions" ,python-typing-extensions)))
+ (native-inputs
+ `(("sox" ,sox)
+ ("python-pytest" ,python-pytest)
+ ("python-pytest-cov" ,python-pytest-cov)
+ ("python-soundfile" ,python-soundfile)))
+ (home-page "https://github.com/rabitt/pysox")
+ (synopsis "Python wrapper around sox")
+ (description
+"@code{pysox} is a wrapper around the @command{sox} command line tool.
+ pysox's API offers @code{Transformer} and @code{Combiner} classes that allow the user to
+incrementally build up effects and audio manipulations. @code{pysox} also
+provides methods for querying audio information such as sample rate,
+determining whether an audio file is silent and much more.")
+ (license license:bsd-3))))
+
(define-public python-pyaudio
(package
(name "python-pyaudio")
--
2.33.0
A
A
Arun Isaac wrote on 16 Oct 2021 12:02
(name . jgart)(address . jgart@dismail.de)(address . 49469@debbugs.gnu.org)
87sfx1s2xh.fsf@systemreboot.net
Hi jgart,

Thanks for the updated patch! Some feedback follows.

Toggle quote (7 lines)
> +(define-public python-pysox
> + (let ((commit "3d0053381c24ae3490f759d4de87194b85789d36")
> + (revision "0"))
> + (package
> + (name "python-pysox")
> + (version (git-version "1.4.2" revision commit))

According to PyPI, it seems that the latest version is 1.4.1.

And, I see that upstream is not tagging releases correctly in their git
repo. Could you raise this issue with upstream?

Toggle quote (6 lines)
> + (source
> + (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/rabitt/pysox")

We should prefer the PyPI source tarball. If there is something missing
in the PyPI source tarball, and that's why you are using the GitHub
source, could you add a comment explaining the reason?

Toggle quote (4 lines)
> + (substitute* "sox/log.py"
> + (("Logger\\('sox")
> + (string-append "Logger\('" sox-bin))))))

I think the above substitution is not required, because in this instance
'sox' is the name of the logger, rather than the full path to the sox
executable.

Toggle quote (3 lines)
> + (setenv "PYTHONPATH" (string-append ".:" (getenv
> "PYTHONPATH")))

This setting of PYTHONPATH does not seem to be required. The tests
succeed without it.

Toggle quote (7 lines)
> + (description
> +"@code{pysox} is a wrapper around the @command{sox} command line tool.
> + pysox's API offers @code{Transformer} and @code{Combiner} classes that allow the user to
> +incrementally build up effects and audio manipulations. @code{pysox} also
> +provides methods for querying audio information such as sample rate,
> +determining whether an audio file is silent and much more.")

I think @code{pysox} should be @code{python-pysox} since we are
referring to the python-pysox scheme variable.

Could you send an updated patch? Also, please do use `git format-patch
-v2', `git format-patch -v3', etc. when sending updated patches.

Thanks!
Arun
-----BEGIN PGP SIGNATURE-----

iQFPBAEBCAA5FiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAmFqoyobHGFydW5pc2Fh
Y0BzeXN0ZW1yZWJvb3QubmV0AAoJEC4l7othgCuzVKYH/0eAAxxWYbb/TfFK37VN
d73FmCBcZ9arPBuCWz+rwkeJyBEeFr8m84tScmZ7yW7CL4Ssjx788YOVWED0us7x
2ZEFDoGFN/GDWS1RVfCstqeodWuT463VTOGhNR3s4oRBhzIA0YV6cb791D7Qj2Zp
3kij2Z2hohvEtqK/HIb7x311lCF8PoJJbJl4ONT2twPLEZaVMkzCa8cgpFtYbIyr
8VaHQ5+5V/TpfcMSCJyW3okxO0tSWsfnkTTz7+rDYkzV80ZFHPMFEBVXMlWWMs3n
PlIHCrhF/x0cu+G6qjXnYlJt+yLSS6tJuNWbNroW0twUgozIPEiD3Nz7xehRqsnu
p08=
=HsEa
-----END PGP SIGNATURE-----

A
A
Arun Isaac wrote on 16 Oct 2021 12:05
(name . jgart)(address . jgart@dismail.de)(address . 49469@debbugs.gnu.org)
87o87ps2rx.fsf@systemreboot.net
Also, in the next patch, please add a copyright header for yourself.

Thanks!
-----BEGIN PGP SIGNATURE-----

iQFPBAEBCAA5FiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAmFqo/IbHGFydW5pc2Fh
Y0BzeXN0ZW1yZWJvb3QubmV0AAoJEC4l7othgCuzilQH/3VBJvfwV0aOf7gin90N
7Fk28TwCokSHS5GTJB/Vg8V0295miiUsKU8jIj6mCnBQL3CNxq/6HqKWSgNx9qHb
IUKvuEJxGHfYhZCgolQpdC4jXvjhFwZzG/TmOql+30BrE9Z7mklHCXNfp9tcrApL
Kldnprj7YYBkA1Pa3XQmSkbvr0wpy2Ku5OO4ZGLUKsg3lEjq2VE6edavqYfYyGRR
ppTEQH9FKgUxlg0Kzvsx+OviKkbYUJ94lTMysUPOswJy+D7wprfRYGoF1JzLGR/R
7mYX5AajkRTBQf2UFf2hx2rtyxLRntxGNV1RL1Q5UF1XeyWczN0WwO26fdyIGKEF
5Lk=
=VNIK
-----END PGP SIGNATURE-----

A
A
Arun Isaac wrote on 24 Nov 2021 17:25
(name . jgart)(address . jgart@dismail.de)(address . 49469@debbugs.gnu.org)
87k0gx8qsh.fsf@systemreboot.net
Hi jgart,

Just a gentle reminder. I was wondering if you missed my last mail on
this patch.

Thanks,
Arun
-----BEGIN PGP SIGNATURE-----

iQFPBAEBCAA5FiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAmGeZ14bHGFydW5pc2Fh
Y0BzeXN0ZW1yZWJvb3QubmV0AAoJEC4l7othgCuzulIH/RA3UVamZFhsXfNmDTUL
A39uN89+fgyAc75LzfbdFHPpQjPrp+TnlmwDVHmURNJLpkCU1GOna74ApNdgzNy9
IyDPeiGJNmVSm3IH1vPtD9Ut98G3yiOYN5NNkHQ/tNSWrOe2F8tNJN8+hayQy1Uh
5Zz3uVrZioh6fL+ez87fKTtWb4Fol3U+STZMX0MT795xqaoO5+93SLAuFd/uorEQ
D87jSTMwqoIGjZQCf2sFowuyrKcMQQwycxzvh/ej1QhwpBsh6yX5v8NOqne8zUUk
ibDFtFQaf7U3dkHH58R5FLjq2o38ElTlwoZGWulIGMlYjlELaxa4XliKsl6JPN0S
T/c=
=/ji/
-----END PGP SIGNATURE-----

J
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 49469@debbugs.gnu.org)
20211124233328.GB22950@gac.attlocal.net
On Wed, 24 Nov 2021 21:55:02 +0530 Arun Isaac <arunisaac@systemreboot.net> wrote:
Toggle quote (9 lines)
>
> Hi jgart,
>
> Just a gentle reminder. I was wondering if you missed my last mail on
> this patch.
>
> Thanks,
> Arun

Hi Arun,

Thank you for taking the time to review these patches.

Oddly enough, PyPi does not include the data folder that contains the audio files required for testing:


Here is a snippet of the log showing test failures from not finding the data folder with the audio files:

/gnu/store/grnpyl2q67cyymcx7p27h5l64i23i4bn-python-pysox-1.4.1/lib/python3.8/site-packages/sox/file_info.py:248: OSError
________________ TestTransformerVol.test_limiter_gain_vol_up_db ________________

self = <test_transform.TestTransformerVol testMethod=test_limiter_gain_vol_up_db>

def test_limiter_gain_vol_up_db(self):
tfm = new_transformer()
tfm.vol(2.0, gain_type='db', limiter_gain=0.05)

actual_args = tfm.effects
expected_args = ['vol', '2.000000', 'dB', '0.050000']
self.assertEqual(expected_args, actual_args)

actual_log = tfm.effects_log
expected_log = ['vol']
self.assertEqual(expected_log, actual_log)

Toggle quote (2 lines)
> actual_res = tfm.build(INPUT_FILE, OUTPUT_FILE)

tests/test_transform.py:5322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/grnpyl2q67cyymcx7p27h5l64i23i4bn-python-pysox-1.4.1/lib/python3.8/site-packages/sox/transform.py:593: in build
input_format, input_filepath = self._parse_inputs(
/gnu/store/grnpyl2q67cyymcx7p27h5l64i23i4bn-python-pysox-1.4.1/lib/python3.8/site-packages/sox/transform.py:493: in _parse_inputs
file_info.validate_input_file(input_filepath)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input_filepath = '/tmp/guix-build-python-pysox-1.4.1.drv-0/sox-1.4.1/tests/data/input.wav'

def validate_input_file(input_filepath):
'''Input file validation function. Checks that file exists and can be
processed by SoX.

Parameters
----------
input_filepath : str
The input filepath.

'''
if not os.path.exists(input_filepath):
Toggle quote (1 lines)
> raise IOError(
"input_filepath {} does not exist.".format(input_filepath)
)
E OSError: input_filepath /tmp/guix-build-python-pysox-1.4.1.drv-0/sox-1.4.1/tests/data/input.wav does not exist.

/gnu/store/grnpyl2q67cyymcx7p27h5l64i23i4bn-python-pysox-1.4.1/lib/python3.8/site-packages/sox/file_info.py:248: OSError
================= 282 failed, 373 passed, 10 skipped in 51.02s =================


Next email will contain the new patch set with your suggestions. I've included a copyright statement also.

Thank you!

all best,

jgart
J
[PATCH v3] gnu: Add python-pysox.
(address . 49469@debbugs.gnu.org)(name . jgart)(address . jgart@dismail.de)
20211125044245.25678-1-jgart@dismail.de
* gnu/packages/audio.scm (python-pysox): New variable.
---
gnu/packages/audio.scm | 56 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

Toggle diff (76 lines)
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 4b1a602804..694ea1a21b 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -34,6 +34,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net>
;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
+;;; Copyright © 2021 jgart <jgart@dismail.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -5532,6 +5533,61 @@ (define-public siggen
device. There is support for mono and/or stereo and 8 or 16 bit samples.")
(license license:gpl2)))
+(define-public python-pysox
+ ;; PyPi does not include the data folder containing audio files for testing.
+ (let ((commit "3d0053381c24ae3490f759d4de87194b85789d36")
+ (revision "0"))
+ (package
+ (name "python-pysox")
+ (version (git-version "1.4.2" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/rabitt/pysox")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0i62jx92vfpcr2z7lp69yzqdi9idfs3pifl3rzm2akc2c4cr1mac"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-sox
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((sox-store-path (assoc-ref inputs "sox"))
+ (sox-bin (string-append sox-store-path "/bin/sox")))
+ (substitute* "sox/__init__.py"
+ (("sox -h")
+ (string-append sox-bin " -h")))
+ (substitute* "sox/core.py"
+ (("\\['sox")
+ (string-append "['" sox-bin))))))
+ (replace 'check
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest")))))))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-typing-extensions" ,python-typing-extensions)))
+ (native-inputs
+ `(("sox" ,sox)
+ ("python-pytest" ,python-pytest)
+ ("python-pytest-cov" ,python-pytest-cov)
+ ("python-soundfile" ,python-soundfile)))
+ (home-page "https://github.com/rabitt/pysox")
+ (synopsis "Python wrapper around SoX")
+ (description
+"@code{python-pysox} is a wrapper around the @command{sox} command
+line tool. The API offers @code{Transformer} and @code{Combiner}
+classes that allow the user to incrementally build up effects and audio
+manipulations. @code{python-pysox} also provides methods for querying
+audio information such as sample rate, determining whether an audio file
+is silent, and much more.")
+ (license license:bsd-3))))
+
(define-public mda-lv2
(package
(name "mda-lv2")
--
2.34.0
J
Re: bug#49469: [PATCH] gnu: Add python-pysox.
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 49469@debbugs.gnu.org)
20211124234634.GB25725@gac.attlocal.net
On Wed, 24 Nov 2021 23:33:28 -0500 jgart <jgart@dismail.de> wrote:

I sent the latest patch set (v3) but forgot to Cc you ;)

all best,

jgart
A
A
Arun Isaac wrote on 29 Nov 2021 17:12
(name . jgart)(address . jgart@dismail.de)(address . 49469-done@debbugs.gnu.org)
87a6hnrldj.fsf@systemreboot.net
Hi jgart,

Thank you for your revised patch! I have pushed it to master.

Toggle quote (3 lines)
> Oddly enough, PyPi does not include the data folder that contains the
> audio files required for testing:

Personally, I believe this is bad practice, but sadly it is quite
common.

Regards,
Arun
-----BEGIN PGP SIGNATURE-----

iQFPBAEBCAA5FiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAmGk/AgbHGFydW5pc2Fh
Y0BzeXN0ZW1yZWJvb3QubmV0AAoJEC4l7othgCuzb9oIAIfEg1Ile2WFJF+9NLIJ
Guf5cDU/J08MFtQZ9wREY1RSZ3uA40G15M/ohRsL7HcACC0jwdW/IISE9DHKVCAd
duxXgqfHdq2eeve/t7bWL8urH0dHqQb/pnqpe9M9djQaWpGnckU1vnAUKRk+2vK8
R7jUMWlaofQ7ocWyC6Xup7UimFcxhjiDT3Qd685WJClAXNTCy8AdudhTMlt4BkHQ
JsrpqA57huEC5T+X48uFCdIhnc4Y0v8mf3bh41cA+5Tn9vpJkXbE/gmIRidlLyU8
fQ8XdaXgojSaay7P+f8OU45kIIe47ccxUU0Rv1gHQiWinoxuRqvYJ1OadFgbw2T2
uFo=
=N27T
-----END PGP SIGNATURE-----

Closed
?