Skip to content

Commit 11c47cf

Browse files
committed
Mock libsamplerate for RTD
1 parent 3f00aea commit 11c47cf

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

samplerate/lowlevel.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
from samplerate._src import ffi
1414
lib_basename = 'libsamplerate'
1515
lib_filename = _find_library('samplerate')
16-
if lib_filename is None:
16+
17+
if _os.environ.get('READTHEDOCS') == 'True':
18+
# Mock minimum C API for Read the Docs
19+
class MockLib(object):
20+
@classmethod
21+
def src_get_version(cls):
22+
return ffi.new('char[]', 'libsamplerate-0.1.9 (c) ...')
23+
lib_filename = 'mock'
24+
_lib = MockLib()
25+
elif lib_filename is None:
1726
if _sys.platform == 'darwin':
1827
lib_filename = '{}.dylib'.format(lib_basename)
1928
elif _sys.platform == 'win32':
@@ -24,8 +33,9 @@
2433
lib_filename = _os.path.join(
2534
_os.path.dirname(_os.path.abspath(__file__)), '_samplerate_data',
2635
lib_filename)
27-
28-
_lib = ffi.dlopen(lib_filename)
36+
_lib = ffi.dlopen(lib_filename)
37+
else:
38+
_lib = ffi.dlopen(lib_filename)
2939

3040

3141
def _check_data(data):

0 commit comments

Comments
 (0)