Skip to content

Commit acffb86

Browse files
committed
build system preparation for release 0.11.0
_soundfile_data now contains up-to-date binaries for Windows 32/64 and macOS intel/arm. build scripts have been amended to use the new binaries changelog is not yet updated windows binaries use different C runtime than python, do not support file descriptors
1 parent d41120a commit acffb86

File tree

4 files changed

+34
-36
lines changed

4 files changed

+34
-36
lines changed

build_wheels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import shutil
33

4-
architectures = dict(darwin=['64bit'],
4+
architectures = dict(darwin=['x86_64', 'arm64'],
55
win32=['32bit', '64bit'],
66
noplatform='noarch')
77

setup.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,14 @@
55
from setuptools.command.test import test as TestCommand
66
import sys
77

8-
PYTHON_INTERPRETERS = '.'.join([
9-
'cp26', 'cp27',
10-
'cp32', 'cp33', 'cp34', 'cp35', 'cp36',
11-
'pp27',
12-
'pp32', 'pp33',
13-
])
14-
MACOSX_VERSIONS = '.'.join([
15-
'macosx_10_5_x86_64',
16-
'macosx_10_6_intel',
17-
'macosx_10_9_intel',
18-
'macosx_10_9_x86_64',
19-
])
20-
218
# environment variables for cross-platform package creation
229
platform = os.environ.get('PYSOUNDFILE_PLATFORM', sys.platform)
2310
architecture0 = os.environ.get('PYSOUNDFILE_ARCHITECTURE', architecture()[0])
2411

2512
if platform == 'darwin':
26-
libname = 'libsndfile.dylib'
13+
libname = 'libsndfile_' + architecture0 + '.dylib'
2714
elif platform == 'win32':
28-
libname = 'libsndfile' + architecture0 + '.dll'
15+
libname = 'libsndfile_' + architecture0 + '.dll'
2916
else:
3017
libname = None
3118

@@ -70,9 +57,12 @@ class bdist_wheel_half_pure(bdist_wheel):
7057
"""Create OS-dependent, but Python-independent wheels."""
7158

7259
def get_tag(self):
73-
pythons = 'py2.py3.' + PYTHON_INTERPRETERS
60+
pythons = 'py2.py3'
7461
if platform == 'darwin':
75-
oses = MACOSX_VERSIONS
62+
if architecture0 == 'x86_64':
63+
oses = 'macosx-10.x-x86_64'
64+
else:
65+
oses = 'macosx-10.x-arm64'
7666
elif platform == 'win32':
7767
if architecture0 == '32bit':
7868
oses = 'win32'
@@ -87,7 +77,7 @@ def get_tag(self):
8777

8878
setup(
8979
name='soundfile',
90-
version='0.10.3post1',
80+
version='0.11.0b1',
9181
description='An audio library based on libsndfile, CFFI and NumPy',
9282
author='Bastian Bechtold',
9383
author_email='[email protected]',

soundfile.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
For further information, see https://python-soundfile.readthedocs.io/.
99
1010
"""
11-
__version__ = "0.10.3"
11+
__version__ = "0.11.0"
1212

1313
import os as _os
1414
import sys as _sys
15-
from platform import machine as _machine
1615
from os import SEEK_SET, SEEK_CUR, SEEK_END
1716
from ctypes.util import find_library as _find_library
1817
from _soundfile import ffi as _ffi
@@ -144,10 +143,16 @@
144143
_snd = _ffi.dlopen(_libname)
145144
except OSError:
146145
if _sys.platform == 'darwin':
146+
from platform import machine as _machine
147+
_packaged_libname = 'libsndfile_' + machine() + '.dylib'
147148
_libname = 'libsndfile.dylib'
148149
elif _sys.platform == 'win32':
149150
from platform import architecture as _architecture
150-
_libname = 'libsndfile' + _architecture()[0] + '.dll'
151+
_packaged_libname = 'libsndfile_' + _architecture()[0] + '.dll'
152+
_libname = 'libsndfile.dll'
153+
elif _sys.platform == 'linux':
154+
_packaged_libname = 'libsndfile.so' # not provided!
155+
_libname = 'libsndfile.so'
151156
else:
152157
raise
153158

@@ -160,16 +165,19 @@
160165
while not _os.path.isdir(_path):
161166
_path = _os.path.abspath(_os.path.join(_path, '..'))
162167

163-
# Homebrew on Apple M1 uses a `/opt/homebrew/lib` instead of
164-
# `/usr/local/lib`. We are making sure we pick that up.
165-
if _sys.platform == 'darwin' and _machine() == 'arm64':
166-
_hbrew_path = '/opt/homebrew/lib/' if _os.path.isdir('/opt/homebrew/lib/') \
167-
else '/usr/local/lib/'
168-
_snd = _ffi.dlopen(_os.path.join(
169-
_hbrew_path, _libname))
170-
else:
171-
_snd = _ffi.dlopen(_os.path.join(
172-
_path, '_soundfile_data', _libname))
168+
try: # packaged libsndfile:
169+
_snd = _ffi.dlopen(_os.path.join(_path, '_soundfile_data', _packaged_libname))
170+
except OSError: # try system-wide libsndfile:
171+
# Homebrew on Apple M1 uses a `/opt/homebrew/lib` instead of
172+
# `/usr/local/lib`. We are making sure we pick that up.
173+
from platform import machine as _machine
174+
if _sys.platform == 'darwin' and _machine() == 'arm64':
175+
_hbrew_path = '/opt/homebrew/lib/' if _os.path.isdir('/opt/homebrew/lib/') \
176+
else '/usr/local/lib/'
177+
_snd = _ffi.dlopen(_os.path.join(_hbrew_path, _libname))
178+
else:
179+
# Try explicit file name, if the general does not work (e.g. on nixos)
180+
_snd = _ffi.dlopen(_libname)
173181

174182
__libsndfile_version__ = _ffi.string(_snd.sf_version_string()).decode('utf-8', 'replace')
175183
if __libsndfile_version__.startswith('libsndfile-'):
@@ -1368,9 +1376,9 @@ def copy_metadata(self):
13681376
-------
13691377
13701378
metadata: dict[str, str]
1371-
A dict with all metadata. Possible keys are: 'title', 'copyright',
1372-
'software', 'artist', 'comment', 'date', 'album', 'license',
1373-
'tracknumber' and 'genre'.
1379+
A dict with all metadata. Possible keys are: 'title', 'copyright',
1380+
'software', 'artist', 'comment', 'date', 'album', 'license',
1381+
'tracknumber' and 'genre'.
13741382
"""
13751383
strs = {}
13761384
for strtype, strid in _str_types.items():

0 commit comments

Comments
 (0)