commit:     f29a2197112517666901f840a9cb59510b878f54
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  2 21:48:37 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun  2 21:49:31 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f29a2197

dev-python/pyalsa: enable py3.12

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

 .../pyalsa/files/pyalsa-1.2.7-python3.12.patch     | 34 +++++++++++++
 dev-python/pyalsa/pyalsa-1.2.7-r2.ebuild           | 55 ++++++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/dev-python/pyalsa/files/pyalsa-1.2.7-python3.12.patch 
b/dev-python/pyalsa/files/pyalsa-1.2.7-python3.12.patch
new file mode 100644
index 000000000000..f27a7714a986
--- /dev/null
+++ b/dev-python/pyalsa/files/pyalsa-1.2.7-python3.12.patch
@@ -0,0 +1,34 @@
+https://github.com/alsa-project/alsa-python/issues/9
+https://github.com/alsa-project/alsa-python/pull/10
+https://github.com/alsa-project/alsa-python/commit/cb75f5cdba0a29bdfa43eb56285da4917d2941a9
+
+From cb75f5cdba0a29bdfa43eb56285da4917d2941a9 Mon Sep 17 00:00:00 2001
+From: Francesco Ceruti <[email protected]>
+Date: Sat, 4 May 2024 22:16:16 +0200
+Subject: [PATCH] alsaseq: fix seg. fault when accessing `ConstantObject` extra
+
+Closes: https://github.com/alsa-project/alsa-python/pull/10
+Signed-off-by: Francesco Ceruti <[email protected]>
+Signed-off-by: Jaroslav Kysela <[email protected]>
+--- a/pyalsa/alsaseq.c
++++ b/pyalsa/alsaseq.c
+@@ -353,18 +353,11 @@ typedef struct {
+ } ConstantObject;
+ 
+ #if PY_MAJOR_VERSION < 3
+-/* PyInt is fixed size in Python 2 */
+ # define CONST_VALUE(x) PyInt_AsLong((PyObject *)x)
+-# define CONST_EXTRA(x) (&(x->extra))
+ #else
+-/* PyLong is variable size in Python 3 */
+ # define CONST_VALUE(x) PyLong_AsLong((PyObject *)x)
+-# define CONST_EXTRA(x) \
+-    ((ConstantExtraFields *)( \
+-        ((intptr_t)(&x->extra)) \
+-        + abs(Py_SIZE(&x->base)) * Py_TYPE(x)->tp_itemsize \
+-    ))
+ #endif
++# define CONST_EXTRA(x) (&(x->extra))
+ 
+ /** alsaseq.Constant type (initialized later...) */
+ static PyTypeObject ConstantType;

diff --git a/dev-python/pyalsa/pyalsa-1.2.7-r2.ebuild 
b/dev-python/pyalsa/pyalsa-1.2.7-r2.ebuild
new file mode 100644
index 000000000000..2632cb21b9c9
--- /dev/null
+++ b/dev-python/pyalsa/pyalsa-1.2.7-r2.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit distutils-r1
+
+DESCRIPTION="Python bindings for ALSA library"
+HOMEPAGE="https://alsa-project.org/wiki/Main_Page";
+SRC_URI="https://www.alsa-project.org/files/pub/pyalsa/${P}.tar.bz2";
+
+LICENSE="LGPL-2.1+"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~sparc 
~x86"
+# Needs access to system's alsa configuration/devices
+RESTRICT="test"
+
+DEPEND="
+       media-libs/alsa-lib
+"
+RDEPEND="
+       ${DEPEND}
+"
+BDEPEND="
+       dev-python/setuptools[${PYTHON_USEDEP}]
+"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-1.1.6-no-build-symlinks.patch"
+       "${FILESDIR}/${PN}-1.2.7-python3.12.patch"
+)
+
+python_test() {
+       cd "${T}" || die
+
+       shopt -s nullglob
+       local test
+       local failed
+       for test in "${S}"/test/*.py ; do
+               ${EPYTHON} "${test}" || {
+                       eerror "${test} failed with ${EPYTHON}"
+                       failed=1
+                       break
+               }
+       done
+       shopt -u nullglob
+
+       if [[ ${failed} -eq 1 ]] ; then
+               die "${test} failed with ${EPYTHON}"
+       fi
+}

Reply via email to