diff --git a/.gitignore b/.gitignore index a60286d..90728d2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,10 @@ __pycache__ dist build PySoundFile.egg-info -MANIFEST \ No newline at end of file +MANIFEST +*.pyc +*.wav +*.raw +delme.please +.coverage +.cache diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..034ecad --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include pysoundfile/win sndfile32.dll sndfile64.dll sndfile_license diff --git a/dist/PySoundFile-0.4.1.win-amd64-py2.7.exe b/dist/PySoundFile-0.4.1.win-amd64-py2.7.exe deleted file mode 100644 index 3c6358e..0000000 Binary files a/dist/PySoundFile-0.4.1.win-amd64-py2.7.exe and /dev/null differ diff --git a/dist/PySoundFile-0.4.1.win-amd64-py3.3.exe b/dist/PySoundFile-0.4.1.win-amd64-py3.3.exe deleted file mode 100644 index 879773d..0000000 Binary files a/dist/PySoundFile-0.4.1.win-amd64-py3.3.exe and /dev/null differ diff --git a/dist/PySoundFile-0.4.1.win32-py2.7.exe b/dist/PySoundFile-0.4.1.win32-py2.7.exe deleted file mode 100644 index d4911ae..0000000 Binary files a/dist/PySoundFile-0.4.1.win32-py2.7.exe and /dev/null differ diff --git a/dist/PySoundFile-0.4.1.win32-py3.3.exe b/dist/PySoundFile-0.4.1.win32-py3.3.exe deleted file mode 100644 index 0c13c02..0000000 Binary files a/dist/PySoundFile-0.4.1.win32-py3.3.exe and /dev/null differ diff --git a/pysoundfile.py b/pysoundfile/__init__.py similarity index 99% rename from pysoundfile.py rename to pysoundfile/__init__.py index 95febf7..e1847c4 100644 --- a/pysoundfile.py +++ b/pysoundfile/__init__.py @@ -14,6 +14,9 @@ from cffi import FFI as _FFI from os import SEEK_SET, SEEK_CUR, SEEK_END +from sys import platform +from platform import architecture + try: import builtins as _builtins except ImportError: @@ -241,7 +244,14 @@ _np.dtype('int16'): 'short' } -_snd = _ffi.dlopen('sndfile') + +try: + _snd = _ffi.dlopen('sndfile') +except OSError: + if _platform == 'win32': + _snd = _ffi.dlopen('sndfile' + _architecture()[0][:2]) # sndfile32/64 + else: + raise def read(file, frames=-1, start=0, stop=None, dtype='float64', always_2d=True, diff --git a/win/sndfile32.dll b/pysoundfile/win/sndfile32.dll similarity index 100% rename from win/sndfile32.dll rename to pysoundfile/win/sndfile32.dll diff --git a/win/sndfile64.dll b/pysoundfile/win/sndfile64.dll similarity index 100% rename from win/sndfile64.dll rename to pysoundfile/win/sndfile64.dll diff --git a/win/sndfile_license b/pysoundfile/win/sndfile_license similarity index 100% rename from win/sndfile_license rename to pysoundfile/win/sndfile_license diff --git a/setup.py b/setup.py index d54e48b..7841532 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,10 @@ #!/usr/bin/env python +import setuptools from setuptools import setup 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 = [] setup( name='PySoundFile', @@ -21,8 +14,7 @@ author_email='basti@bastibe.de', url='https://github.com/bastibe/PySoundFile', keywords=['audio', 'libsndfile'], - py_modules=['pysoundfile'], - data_files=sndfile, + packages=setuptools.find_packages(), license='BSD 3-Clause License', install_requires=['numpy', 'cffi>=0.6'], @@ -41,4 +33,11 @@ 'Topic :: Multimedia :: Sound/Audio' ], long_description=open('README.rst').read(), + zip_safe=False, + include_package_data=True, + package_data={'pysoundfile': [ + 'pysoundfile/win/sndfile32.dll', + 'pysoundfile/win/sndfile64.dll', + 'pysoundfile/win/sndfile_license'] + }, )