Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include LICENSE
graft win
recursive-include doc *.py *.rst *.txt Makefile
recursive-include tests *.py *.wav *.raw
13 changes: 12 additions & 1 deletion pysoundfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import os as _os
from cffi import FFI as _FFI
from os import SEEK_SET, SEEK_CUR, SEEK_END
from sys import platform as _platform
from platform import architecture as _architecture

_ffi = _FFI()
_ffi.cdef("""
Expand Down Expand Up @@ -238,7 +240,16 @@
_np.dtype('int16'): 'short'
}

_snd = _ffi.dlopen('sndfile')
try:
_snd = _ffi.dlopen('sndfile')
except OSError as e:
if _platform == 'win32':
try:
_snd = _ffi.dlopen('libsndfile-1')
except OSError:
_snd = _ffi.dlopen('sndfile' + _architecture()[0])
else:
raise e


def read(file, frames=-1, start=0, stop=None, dtype='float64', always_2d=True,
Expand Down
22 changes: 8 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#!/usr/bin/env python
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
from sys import platform
from platform import architecture
import shutil

if platform == 'win32' and architecture()[0] == '32bit':
shutil.copy2('win/sndfile32.dll', 'win/sndfile.dll')
sndfile = [('', ['win/sndfile.dll', 'win/sndfile_license'])]
elif platform == 'win32' and architecture()[0] == '64bit':
shutil.copy2('win/sndfile64.dll', 'win/sndfile.dll')
sndfile = [('', ['win/sndfile.dll', 'win/sndfile_license'])]
else:
sndfile = []


class PyTest(TestCommand):
Expand All @@ -30,6 +17,7 @@ def finalize_options(self):

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import sys
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
Expand All @@ -44,7 +32,13 @@ def run_tests(self):
url='https://github.com/bastibe/PySoundFile',
keywords=['audio', 'libsndfile'],
py_modules=['pysoundfile'],
data_files=sndfile,
data_files=[
('', [
'win/sndfile64bit.dll',
'win/sndfile32bit.dll',
'win/sndfile_license'
])
],
license='BSD 3-Clause License',
install_requires=['numpy',
'cffi>=0.6'],
Expand Down
File renamed without changes.
File renamed without changes.