From 0cdb3266cdd5c81997d58e060e0ed1973fdf888699869533b6fa0117549cd6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Wed, 7 May 2025 07:49:55 +0000 Subject: [PATCH] - Convert to pip-based build OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PyAudio?expand=0&rev=14 --- .gitattributes | 23 +++++++ .gitignore | 1 + PyAudio-0.2.11.tar.gz | 3 + loopback_required.patch | 144 ++++++++++++++++++++++++++++++++++++++++ python-PyAudio.changes | 56 ++++++++++++++++ python-PyAudio.spec | 75 +++++++++++++++++++++ 6 files changed, 302 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 PyAudio-0.2.11.tar.gz create mode 100644 loopback_required.patch create mode 100644 python-PyAudio.changes create mode 100644 python-PyAudio.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/PyAudio-0.2.11.tar.gz b/PyAudio-0.2.11.tar.gz new file mode 100644 index 0000000..b9f70e1 --- /dev/null +++ b/PyAudio-0.2.11.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93bfde30e0b64e63a46f2fd77e85c41fd51182a4a3413d9edfaf9ffaa26efb74 +size 37428 diff --git a/loopback_required.patch b/loopback_required.patch new file mode 100644 index 0000000..f706bcb --- /dev/null +++ b/loopback_required.patch @@ -0,0 +1,144 @@ +--- + tests/__init__.py | 3 +++ + tests/error_tests.py | 5 +++++ + tests/pyaudio_tests.py | 11 +++++++++++ + 3 files changed, 19 insertions(+) + +--- /dev/null ++++ b/tests/__init__.py +@@ -0,0 +1,3 @@ ++import os ++ ++HARDWARE = 'HW_REQUIRED' in os.environ +--- a/tests/error_tests.py ++++ b/tests/error_tests.py +@@ -3,6 +3,7 @@ import time + import unittest + + import pyaudio ++from tests import HARDWARE + + class PyAudioErrorTests(unittest.TestCase): + def setUp(self): +@@ -55,6 +56,7 @@ class PyAudioErrorTests(unittest.TestCas + input=True) + stream.write('foo') + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_error_negative_frames(self): + with self.assertRaises(ValueError): + stream = self.p.open(channels=1, +@@ -63,6 +65,7 @@ class PyAudioErrorTests(unittest.TestCas + input=True) + stream.read(-1) + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_invalid_attr_on_closed_stream(self): + stream = self.p.open(channels=1, + rate=44100, +@@ -81,6 +84,7 @@ class PyAudioErrorTests(unittest.TestCas + with self.assertRaises(ValueError): + self.p.is_format_supported(8000, 0, -1, pyaudio.paInt16) + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_write_underflow_exception(self): + stream = self.p.open(channels=1, + rate=44100, +@@ -100,6 +104,7 @@ class PyAudioErrorTests(unittest.TestCas + self.assertEqual(err.exception.errno, pyaudio.paOutputUnderflowed) + self.assertEqual(err.exception.strerror, 'Output underflowed') + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_read_overflow_exception(self): + stream = self.p.open(channels=1, + rate=44100, +--- a/tests/pyaudio_tests.py ++++ b/tests/pyaudio_tests.py +@@ -22,6 +22,7 @@ import sys + import numpy + + import pyaudio ++from tests import HARDWARE + + DUMP_CAPTURE=False + +@@ -71,6 +72,7 @@ class PyAudioTests(unittest.TestCase): + + return input_idx, output_idx + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_system_info(self): + """Basic system info tests""" + self.assertTrue(self.p.get_host_api_count() > 0) +@@ -78,6 +80,7 @@ class PyAudioTests(unittest.TestCase): + api_info = self.p.get_host_api_info_by_index(0) + self.assertTrue(len(api_info.items()) > 0) + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_input_output_blocking(self): + """Test blocking-based record and playback.""" + rate = 44100 # frames per second +@@ -138,6 +141,7 @@ class PyAudioTests(unittest.TestCase): + test_signal, + len(freqs)) + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_input_output_callback(self): + """Test callback-based record and playback.""" + rate = 44100 # frames per second +@@ -207,6 +211,7 @@ class PyAudioTests(unittest.TestCase): + test_signal, + len(freqs)) + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_device_lock_gil_order(self): + """Ensure no deadlock between Pa_{Open,Start,Stop}Stream and GIL.""" + # This test targets OSX/macOS CoreAudio, which seems to use +@@ -262,6 +267,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_stream_state_gil(self): + """Ensure no deadlock between Pa_IsStream{Active,Stopped} and GIL.""" + rate = 44100 # frames per second +@@ -322,6 +328,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_time_gil(self): + """Ensure no deadlock between PA_GetStreamTime and GIL.""" + rate = 44100 # frames per second +@@ -376,6 +383,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_cpuload_gil(self): + """Ensure no deadlock between Pa_GetStreamCpuLoad and GIL.""" + rate = 44100 # frames per second +@@ -430,6 +438,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_write_available_gil(self): + """Ensure no deadlock between Pa_GetStreamWriteAvailable and GIL.""" + rate = 44100 # frames per second +@@ -477,6 +486,7 @@ class PyAudioTests(unittest.TestCase): + time.sleep(0.1) + in_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_read_available_gil(self): + """Ensure no deadlock between Pa_GetStreamReadAvailable and GIL.""" + rate = 44100 # frames per second +@@ -524,6 +534,7 @@ class PyAudioTests(unittest.TestCase): + time.sleep(0.1) + in_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_terminate_gil(self): + """Ensure no deadlock between Pa_Terminate and GIL.""" + rate = 44100 # frames per second diff --git a/python-PyAudio.changes b/python-PyAudio.changes new file mode 100644 index 0000000..e3fe6c5 --- /dev/null +++ b/python-PyAudio.changes @@ -0,0 +1,56 @@ +------------------------------------------------------------------- +Tue May 6 12:00:12 UTC 2025 - Markéta Machová + +- Convert to pip-based build + +------------------------------------------------------------------- +Mon Feb 7 14:14:04 UTC 2022 - Matej Cepl + +- Add loopback_required.patch which allows skipping over tests + requiring special hardware without pytest. The issue reported + upstream by email. + +------------------------------------------------------------------- +Thu Nov 7 15:06:44 UTC 2019 - Matej Cepl + +- Run through spec-cleaner + +------------------------------------------------------------------- +Mon Aug 28 20:43:35 UTC 2017 - toddrme2178@gmail.com + +- Update to 0.2.11 + * Fix use-after-free memory issue in callback handler. + * Fix docstring for get_output_latency(). +- Update to 0.2.10 + * Release the GIL during PortAudio I/O calls to avoid potential deadlock. + * Add a few automated unit tests. +- Update to PyAudio 0.2.9 + * Fix overflow error handling logic for pa_read_stream. + * Fix IOError arguments. + * Python library surfaces issues with importing low-level C module. + * Code formatting update. + * Updates to examples for Python 3 compatibility. +- Implement single-spec version +- Fix source URL + +------------------------------------------------------------------- +Mon Jul 14 15:30:37 UTC 2014 - toddrme2178@gmail.com + +- Update to 0.2.8 + * bug fixes related to the Python GIL and device name encoding. + +------------------------------------------------------------------- +Thu Oct 24 11:11:25 UTC 2013 - speilicke@suse.com + +- Require python-setuptools instead of distribute (upstreams merged) + +------------------------------------------------------------------- +Fri Nov 2 16:28:05 UTC 2012 - prusnak@opensuse.org + +- updated to 0.2.7 + +------------------------------------------------------------------- +Wed Oct 3 14:33:38 UTC 2012 - mvyskocil@suse.com + +- initial packaging of python-PyAudio for openSUSE + diff --git a/python-PyAudio.spec b/python-PyAudio.spec new file mode 100644 index 0000000..5b8ce30 --- /dev/null +++ b/python-PyAudio.spec @@ -0,0 +1,75 @@ +# +# spec file for package python-PyAudio +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%bcond_without test +Name: python-PyAudio +Version: 0.2.11 +Release: 0 +Summary: Python Bindings for PortAudio v19 +License: MIT +URL: https://people.csail.mit.edu/hubert/pyaudio/ +Source: https://files.pythonhosted.org/packages/source/P/PyAudio/PyAudio-%{version}.tar.gz +# PATCH-FIX-UPSTREAM loopback_required.patch mcepl@suse.com +# Mark tests requiring specific hardware as such +Patch0: loopback_required.patch +BuildRequires: %{python_module devel} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildRequires: portaudio-devel +BuildRequires: python-rpm-macros +%if %{with test} +BuildRequires: %{python_module numpy} +BuildRequires: alsa +%endif +%python_subpackages + +%description +PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library. +With PyAudio, you can easily use Python to play and record audio streams on a variety +of platforms (e.g., GNU/Linux, Microsoft Windows, and Mac OS X). + +%prep +%setup -q -n PyAudio-%{version} +%autopatch -p1 + +%build +export CFLAGS="%{optflags} -fno-strict-aliasing" +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} + +%if %{with test} +%check +# report send to hubert@mit.edu +export HW_REQUIRED=1 +%pyunittest_arch discover -p '*.py' -v -s tests +%endif + +%files %{python_files} +%doc CHANGELOG README +%doc examples/ +%{python_sitearch}/_portaudio*.so +%{python_sitearch}/pyaudio.py* +%pycache_only %{python_sitearch}/__pycache__/pyaudio*.py* +%{python_sitearch}/[Pp]y[Aa]udio-%{version}*-info + +%changelog