diff options
| -rw-r--r-- | .travis.yml | 13 | ||||
| -rw-r--r-- | setup.py | 9 | ||||
| -rw-r--r-- | sounddevice.py | 28 |
3 files changed, 21 insertions, 29 deletions
diff --git a/.travis.yml b/.travis.yml index 2912abb..e6ec081 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,27 +6,26 @@ matrix: - python: "3.7" - python: "3.6" - python: "3.5" - - python: "2.7" - python: "nightly" - python: "pypy3" - os: osx language: generic - name: build docs and check for broken links install: - - pip install -r doc/requirements.txt + - python3 -m pip install -r doc/requirements.txt script: - - python setup.py build_sphinx -b linkcheck -W + - python3 setup.py build_sphinx -b linkcheck -W addons: apt: packages: - pandoc - libportaudio2 install: - - pip install . + - python3 -m pip install . script: - cd /tmp - - python -m sounddevice - - python -c "import sounddevice as sd; print(sd._libname)" - - python -c "import sounddevice as sd; print(sd.get_portaudio_version())" + - python3 -m sounddevice + - python3 -c "import sounddevice as sd; print(sd._libname)" + - python3 -c "import sounddevice as sd; print(sd.get_portaudio_version())" notifications: email: false @@ -10,9 +10,7 @@ for line in open('sounddevice.py'): break PYTHON_INTERPRETERS = '.'.join([ - 'cp26', 'cp27', 'cp32', 'cp33', 'cp34', 'cp35', 'cp36', 'cp37', 'cp38', 'cp39', - 'pp27', 'pp32', 'pp33', 'pp34', 'pp35', 'pp36', 'pp37', ]) MACOSX_VERSIONS = '.'.join([ @@ -50,7 +48,7 @@ else: """Create OS-dependent, but Python-independent wheels.""" def get_tag(self): - pythons = 'py2.py3.' + PYTHON_INTERPRETERS + pythons = 'py3.' + PYTHON_INTERPRETERS if system == 'Darwin': oses = MACOSX_VERSIONS elif system == 'Windows': @@ -59,7 +57,7 @@ else: else: oses = 'win_amd64' else: - pythons = 'py2.py3' + pythons = 'py3' oses = 'any' return pythons, 'none', oses @@ -72,7 +70,7 @@ setup( packages=packages, package_data=package_data, zip_safe=zip_safe, - python_requires='>=2.6', + python_requires='>=3', setup_requires=['CFFI>=1.0'], install_requires=['CFFI>=1.0'], extras_require={'NumPy': ['NumPy']}, @@ -89,7 +87,6 @@ setup( 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Multimedia :: Sound/Audio', ], diff --git a/sounddevice.py b/sounddevice.py index a6382b7..e749f03 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -559,14 +559,14 @@ def query_devices(device=None, kind=None): """ if kind not in ('input', 'output', None): - raise ValueError('Invalid kind: {0!r}'.format(kind)) + raise ValueError('Invalid kind: {!r}'.format(kind)) if device is None and kind is None: return DeviceList(query_devices(i) for i in range(_check(_lib.Pa_GetDeviceCount()))) device = _get_device_id(device, kind, raise_on_error=True) info = _lib.Pa_GetDeviceInfo(device) if not info: - raise PortAudioError('Error querying device {0}'.format(device)) + raise PortAudioError('Error querying device {}'.format(device)) assert info.structVersion == 2 name_bytes = _ffi.string(info.name) try: @@ -596,7 +596,7 @@ def query_devices(device=None, kind=None): } if kind and device_dict['max_' + kind + '_channels'] < 1: raise ValueError( - 'Not an {0} device: {1!r}'.format(kind, device_dict['name'])) + 'Not an {} device: {!r}'.format(kind, device_dict['name'])) return device_dict @@ -642,7 +642,7 @@ def query_hostapis(index=None): for i in range(_check(_lib.Pa_GetHostApiCount()))) info = _lib.Pa_GetHostApiInfo(index) if not info: - raise PortAudioError('Error querying host API {0}'.format(index)) + raise PortAudioError('Error querying host API {}'.format(index)) assert info.structVersion == 1 return { 'name': _ffi.string(info.name).decode(), @@ -858,7 +858,7 @@ class _StreamBase(object): _check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters, samplerate, blocksize, stream_flags, callback_ptr, userdata), - 'Error opening {0}'.format(self.__class__.__name__)) + 'Error opening {}'.format(self.__class__.__name__)) # dereference PaStream** --> PaStream* self._ptr = self._ptr[0] @@ -1493,7 +1493,7 @@ class OutputStream(RawOutputStream): if data.ndim > 1 and data.shape[1] != channels: raise ValueError('Number of channels must match') if data.dtype != dtype: - raise TypeError('dtype mismatch: {0!r} vs {1!r}'.format( + raise TypeError('dtype mismatch: {!r} vs {!r}'.format( data.dtype.name, dtype)) if not data.flags.c_contiguous: raise TypeError('data must be C-contiguous') @@ -1776,8 +1776,6 @@ class DeviceList(tuple): ins=info['max_input_channels'], outs=info['max_output_channels']) for idx, info in enumerate(self)) - if _sys.version_info.major < 3: - return text.encode(_sys.stdout.encoding or 'utf-8', 'replace') return text @@ -1812,7 +1810,7 @@ class CallbackFlags(object): flags = str(self) if not flags: flags = 'no flags set' - return '<sounddevice.CallbackFlags: {0}>'.format(flags) + return '<sounddevice.CallbackFlags: {}>'.format(flags) def __str__(self): return ', '.join(name.replace('_', ' ') for name in dir(self) @@ -1821,8 +1819,6 @@ class CallbackFlags(object): def __bool__(self): return bool(self._flags) - __nonzero__ = __bool__ # For Python 2.x - def __ior__(self, other): if not isinstance(other, CallbackFlags): return NotImplemented @@ -2141,11 +2137,11 @@ class PortAudioError(Exception): def __str__(self): errormsg = self.args[0] if self.args else '' if len(self.args) > 1: - errormsg = '{0} [PaErrorCode {1}]'.format(errormsg, self.args[1]) + errormsg = '{} [PaErrorCode {}]'.format(errormsg, self.args[1]) if len(self.args) > 2: host_api, hosterror_code, hosterror_text = self.args[2] hostname = query_hostapis(host_api)['name'] - errormsg = "{0}: '{1}' [{2} error {3}]".format( + errormsg = "{}: '{}' [{} error {}]".format( errormsg, hosterror_text, hostname, hosterror_code) return errormsg @@ -2637,7 +2633,7 @@ def _check(err, msg=''): errormsg = _ffi.string(_lib.Pa_GetErrorText(err)).decode() if msg: - errormsg = '{0}: {1}'.format(msg, errormsg) + errormsg = '{}: {}'.format(msg, errormsg) if err == _lib.paUnanticipatedHostError: # (gh82) We grab the host error info here rather than inside @@ -2669,7 +2665,7 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False): if idev == odev: id_or_query_string = idev else: - raise ValueError('Input and output device are different: {0!r}' + raise ValueError('Input and output device are different: {!r}' .format(id_or_query_string)) if isinstance(id_or_query_string, int): @@ -2712,7 +2708,7 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False): if raise_on_error: raise ValueError('Multiple ' + kind + ' devices found for ' + repr(id_or_query_string) + ':\n' + - '\n'.join('[{0}] {1}'.format(id, name) + '\n'.join('[{}] {}'.format(id, name) for id, name in matches)) else: return -1 |
