commit:     8718d02e1cad7bfa1dfecc952b6a403ea155c8bc
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  2 12:57:57 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jul  2 13:00:23 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8718d02e

dev-python/pyaudio: fix Python 3.10 compatibility

Closes: https://bugs.gentoo.org/855626
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/pyaudio-0.2.11-python310-size_t.patch    | 28 +++++++++++++++
 dev-python/pyaudio/pyaudio-0.2.11-r2.ebuild        | 42 ++++++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/dev-python/pyaudio/files/pyaudio-0.2.11-python310-size_t.patch 
b/dev-python/pyaudio/files/pyaudio-0.2.11-python310-size_t.patch
new file mode 100644
index 000000000000..445a9b7e9c44
--- /dev/null
+++ b/dev-python/pyaudio/files/pyaudio-0.2.11-python310-size_t.patch
@@ -0,0 +1,28 @@
+https://git.skeh.site/skeh/pyaudio/commit/2ee560056ec889ea7cd3ce1801b796b0939dd540
+https://bugs.gentoo.org/855626
+
+From 2ee560056ec889ea7cd3ce1801b796b0939dd540 Mon Sep 17 00:00:00 2001
+From: Derek Schmidt <[email protected]>
+Date: Tue, 14 Dec 2021 21:46:11 -0700
+Subject: [PATCH] Use Py_ssize_t for tuple return on stream methods
+
+--- a/src/_portaudiomodule.c
++++ b/src/_portaudiomodule.c
+@@ -25,6 +25,7 @@
+  */
+ 
+ #include <stdio.h>
++#define PY_SSIZE_T_CLEAN
+ #include "Python.h"
+ #include "portaudio.h"
+ #include "_portaudiomodule.h"
+@@ -1291,7 +1292,7 @@ int _stream_callback_cfunction(const void *input, void 
*output,
+   PyObject *py_status_flags = PyLong_FromUnsignedLong(statusFlags);
+   PyObject *py_input_data = Py_None;
+   const char *pData;
+-  unsigned output_len;
++  Py_ssize_t output_len;
+   PyObject *py_result;
+ 
+   if (input) {
+

diff --git a/dev-python/pyaudio/pyaudio-0.2.11-r2.ebuild 
b/dev-python/pyaudio/pyaudio-0.2.11-r2.ebuild
new file mode 100644
index 000000000000..b061423018d0
--- /dev/null
+++ b/dev-python/pyaudio/pyaudio-0.2.11-r2.ebuild
@@ -0,0 +1,42 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..10} )
+inherit distutils-r1
+
+MY_PN="PyAudio"
+
+DESCRIPTION="Python bindings for PortAudio"
+HOMEPAGE="http://people.csail.mit.edu/hubert/pyaudio/";
+SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_PN}-${PV}.tar.gz"
+S="${WORKDIR}/${MY_PN}-${PV}"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+# Tests work if you have the correct HW device(s) to test. 0.2.11-r1.
+RESTRICT="test"
+
+RDEPEND="media-libs/portaudio"
+DEPEND="${RDEPEND}"
+BDEPEND="test? ( dev-python/numpy[${PYTHON_USEDEP}] )"
+
+distutils_enable_sphinx sphinx
+distutils_enable_tests unittest
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-0.2.11-python310-size_t.patch
+)
+
+python_test() {
+       elog "These tests require an OS loopback sound device that forwards 
audio"
+       elog "output, generated by PyAudio for playback, and forwards it to an 
input"
+       elog "device, which PyAudio can record and verify against a test 
signal."
+
+       cd tests || die
+       # pyaudio_tests have very complicated runtime requirements, therefore 
skipping them.
+       "${EPYTHON}" -m unittest error_tests -v || die "Tests fail with 
${EPYTHON}"
+}

Reply via email to