|
1 | 1 | #!/usr/bin/env python |
2 | | -import sys |
| 2 | +import os |
| 3 | +from platform import architecture |
3 | 4 | from setuptools import setup |
4 | 5 | from setuptools.command.test import test as TestCommand |
5 | | -from sys import platform |
6 | | -from platform import architecture |
7 | | -import shutil |
| 6 | +import sys |
| 7 | + |
| 8 | +# environment variables for cross-platform package creation |
| 9 | +platform = os.environ.get('PYSOUNDFILE_PLATFORM', sys.platform) |
| 10 | +architecture0 = os.environ.get('PYSOUNDFILE_ARCHITECTURE', architecture()[0]) |
| 11 | + |
| 12 | +if platform == 'darwin': |
| 13 | + libname = 'libsndfile.dylib' |
| 14 | +elif platform == 'win32': |
| 15 | + libname = 'libsndfile' + architecture0 + '.dll' |
| 16 | +else: |
| 17 | + libname = None |
8 | 18 |
|
9 | | -if platform == 'win32' and architecture()[0] == '32bit': |
10 | | - shutil.copy2('win/sndfile32.dll', 'win/sndfile.dll') |
11 | | - sndfile = [('', ['win/sndfile.dll', 'win/sndfile_license'])] |
12 | | -elif platform == 'win32' and architecture()[0] == '64bit': |
13 | | - shutil.copy2('win/sndfile64.dll', 'win/sndfile.dll') |
14 | | - sndfile = [('', ['win/sndfile.dll', 'win/sndfile_license'])] |
| 19 | +if libname: |
| 20 | + packages = ['pysoundfile_data'] |
| 21 | + package_data = {'pysoundfile_data': [libname, 'COPYING']} |
15 | 22 | else: |
16 | | - sndfile = [] |
| 23 | + packages = None |
| 24 | + package_data = None |
17 | 25 |
|
18 | 26 |
|
19 | 27 | class PyTest(TestCommand): |
@@ -44,7 +52,8 @@ def run_tests(self): |
44 | 52 | url='https://github.com/bastibe/PySoundFile', |
45 | 53 | keywords=['audio', 'libsndfile'], |
46 | 54 | py_modules=['soundfile'], |
47 | | - data_files=sndfile, |
| 55 | + packages=packages, |
| 56 | + package_data=package_data, |
48 | 57 | license='BSD 3-Clause License', |
49 | 58 | install_requires=['numpy', |
50 | 59 | 'cffi>=0.6'], |
|
0 commit comments