diff mbox series

[bug#49469,v3] gnu: Add python-pysox.

Message ID 20211125044245.25678-1-jgart@dismail.de
State Accepted
Headers show
Series [bug#49469,v3] gnu: Add python-pysox. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

jgart Nov. 25, 2021, 4:42 a.m. UTC
* gnu/packages/audio.scm (python-pysox): New variable.
---
 gnu/packages/audio.scm | 56 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
diff mbox series

Patch

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")