From e4715de538ed9ce68cb3f39799e7a74672ce8f5f Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Tue, 3 Mar 2015 10:06:20 +0100 Subject: [PATCH 1/3] Also include win/* when creating sdist package --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 90a504a..010e7b1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include LICENSE +graft win recursive-include doc *.py *.rst *.txt Makefile recursive-include tests *.py *.wav *.raw From 965ca4dbe8e349fac0c92a1cc217c57c0550e2eb Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Tue, 3 Mar 2015 12:27:48 +0100 Subject: [PATCH 2/3] Ship all DLLs, load if regular loading fails --- pysoundfile.py | 13 ++++++++++++- setup.py | 17 +++++++---------- win/{sndfile32.dll => sndfile32bit.dll} | Bin win/{sndfile64.dll => sndfile64bit.dll} | Bin 4 files changed, 19 insertions(+), 11 deletions(-) rename win/{sndfile32.dll => sndfile32bit.dll} (100%) rename win/{sndfile64.dll => sndfile64bit.dll} (100%) diff --git a/pysoundfile.py b/pysoundfile.py index 7b58944..d4ae079 100644 --- a/pysoundfile.py +++ b/pysoundfile.py @@ -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(""" @@ -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, diff --git a/setup.py b/setup.py index c4d3eb3..a8387c9 100644 --- a/setup.py +++ b/setup.py @@ -6,15 +6,6 @@ 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): user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] @@ -44,7 +35,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'], diff --git a/win/sndfile32.dll b/win/sndfile32bit.dll similarity index 100% rename from win/sndfile32.dll rename to win/sndfile32bit.dll diff --git a/win/sndfile64.dll b/win/sndfile64bit.dll similarity index 100% rename from win/sndfile64.dll rename to win/sndfile64bit.dll From fa6984e0eacbf4641b3e5b2b5edc5ff3968c238e Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Tue, 3 Mar 2015 12:55:42 +0100 Subject: [PATCH 3/3] Removed unneeded imports in setup.py --- setup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index a8387c9..e7b68dc 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +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 class PyTest(TestCommand): @@ -21,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)