|
| 1 | +import os |
| 2 | +import platform |
1 | 3 | from setuptools import setup |
2 | 4 |
|
3 | 5 | __version__ = "unknown" |
|
8 | 10 | exec(line) |
9 | 11 | break |
10 | 12 |
|
| 13 | +PYTHON_INTERPRETERS = '.'.join([ |
| 14 | + 'cp26', 'cp27', |
| 15 | + 'cp32', 'cp33', 'cp34', 'cp35', |
| 16 | + 'pp27', |
| 17 | + 'pp32', |
| 18 | +]) |
| 19 | +MACOSX_VERSIONS = '.'.join([ |
| 20 | + 'macosx_10_6_x86_64', |
| 21 | +]) |
| 22 | + |
| 23 | +# environment variables for cross-platform package creation |
| 24 | +system = os.environ.get('PYTHON_SOUNDDEVICE_PLATFORM', platform.system()) |
| 25 | +architecture0 = os.environ.get('PYTHON_SOUNDDEVICE_ARCHITECTURE', |
| 26 | + platform.architecture()[0]) |
| 27 | + |
| 28 | +if system == 'Darwin': |
| 29 | + libname = 'libportaudio.dylib' |
| 30 | +elif system == 'Windows': |
| 31 | + libname = 'libportaudio' + architecture0 + '.dll' |
| 32 | +else: |
| 33 | + libname = None |
| 34 | + |
| 35 | +if libname: |
| 36 | + packages = ['_sounddevice_data'] |
| 37 | + package_data = {'_sounddevice_data': [libname, 'README.md']} |
| 38 | +else: |
| 39 | + packages = None |
| 40 | + package_data = None |
| 41 | + |
| 42 | +try: |
| 43 | + from wheel.bdist_wheel import bdist_wheel |
| 44 | +except ImportError: |
| 45 | + cmdclass = {} |
| 46 | +else: |
| 47 | + class bdist_wheel_half_pure(bdist_wheel): |
| 48 | + """Create OS-dependent, but Python-independent wheels.""" |
| 49 | + def get_tag(self): |
| 50 | + pythons = 'py2.py3.' + PYTHON_INTERPRETERS |
| 51 | + if system == 'Darwin': |
| 52 | + oses = MACOSX_VERSIONS |
| 53 | + elif system == 'Windows': |
| 54 | + if architecture0 == '32bit': |
| 55 | + oses = 'win32' |
| 56 | + else: |
| 57 | + oses = 'win_amd64' |
| 58 | + else: |
| 59 | + pythons = 'py2.py3' |
| 60 | + oses = 'any' |
| 61 | + return pythons, 'none', oses |
| 62 | + |
| 63 | + cmdclass = {'bdist_wheel': bdist_wheel_half_pure} |
| 64 | + |
11 | 65 | setup( |
12 | 66 | name="sounddevice", |
13 | 67 | version=__version__, |
14 | 68 | py_modules=["sounddevice"], |
| 69 | + packages=packages, |
| 70 | + package_data=package_data, |
15 | 71 | install_requires=["CFFI"], |
16 | 72 | extras_require={"NumPy": ["NumPy"]}, |
17 | 73 | author="Matthias Geier", |
|
31 | 87 | "Programming Language :: Python :: 3", |
32 | 88 | "Topic :: Multimedia :: Sound/Audio", |
33 | 89 | ], |
| 90 | + cmdclass=cmdclass, |
34 | 91 | ) |
0 commit comments