1""" 2PyAudio v0.2.11: Python Bindings for PortAudio. 3 4Copyright (c) 2006 Hubert Pham 5 6Permission is hereby granted, free of charge, to any person obtaining 7a copy of this software and associated documentation files (the 8"Software"), to deal in the Software without restriction, including 9without limitation the rights to use, copy, modify, merge, publish, 10distribute, sublicense, and/or sell copies of the Software, and to 11permit persons to whom the Software is furnished to do so, subject to 12the following conditions: 13 14The above copyright notice and this permission notice shall be 15included in all copies or substantial portions of the Software. 16 17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY 18OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 19LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20FITNESS FOR A PARTICULAR PURPOSE AND 21NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 22OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 23DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26USE OR OTHER DEALINGS IN THE SOFTWARE. 27""" 28 29import os 30import platform 31import sys 32try: 33 from setuptools import setup, Extension 34except ImportError: 35 from distutils.core import setup, Extension 36 37__version__ = "0.2.11" 38 39# distutils will try to locate and link dynamically against portaudio. 40# 41# If you would rather statically link in the portaudio library (e.g., 42# typically on Microsoft Windows), run: 43# 44# % python setup.py build --static-link 45# 46# Specify the environment variable PORTAUDIO_PATH with the build tree 47# of PortAudio. 48 49STATIC_LINKING = False 50 51if "--static-link" in sys.argv: 52 STATIC_LINKING = True 53 sys.argv.remove("--static-link") 54 55portaudio_path = os.environ.get("PORTAUDIO_PATH", "./portaudio-v19") 56mac_sysroot_path = os.environ.get("SYSROOT_PATH", None) 57 58pyaudio_module_sources = ['src/_portaudiomodule.c'] 59include_dirs = [] 60external_libraries = [] 61extra_compile_args = [] 62extra_link_args = [] 63scripts = [] 64defines = [] 65 66if sys.platform.startswith('dragonfly') or \ 67 sys.platform.startswith('freebsd'): 68 include_dirs = ['/usr/local/include/'] 69 external_libraries = [] 70 extra_link_args = ['/usr/local/lib/libportaudio.so'] 71 72if sys.platform == 'darwin': 73 defines += [('MACOSX', '1')] 74 if mac_sysroot_path: 75 extra_compile_args += ["-isysroot", mac_sysroot_path] 76 extra_link_args += ["-isysroot", mac_sysroot_path] 77elif sys.platform == 'win32': 78 bits = platform.architecture()[0] 79 if '64' in bits: 80 defines.append(('MS_WIN64', '1')) 81 82if not STATIC_LINKING: 83 external_libraries = ['portaudio'] 84 extra_link_args = [] 85else: 86 include_dirs = [os.path.join(portaudio_path, 'include/')] 87 extra_link_args = [ 88 os.path.join(portaudio_path, 'lib/.libs/libportaudio.a') 89 ] 90 91 # platform specific configuration 92 if sys.platform == 'darwin': 93 extra_link_args += ['-framework', 'CoreAudio', 94 '-framework', 'AudioToolbox', 95 '-framework', 'AudioUnit', 96 '-framework', 'Carbon'] 97 elif sys.platform == 'cygwin': 98 external_libraries += ['winmm'] 99 extra_link_args += ['-lwinmm'] 100 elif sys.platform == 'win32': 101 # i.e., Win32 Python with mingw32 102 # run: python setup.py build -cmingw32 103 external_libraries += ['winmm'] 104 extra_link_args += ['-lwinmm'] 105 elif sys.platform == 'linux2': 106 extra_link_args += ['-lrt', '-lm', '-lpthread'] 107 # GNU/Linux has several audio systems (backends) available; be 108 # sure to specify the desired ones here. Start with ALSA and 109 # JACK, since that's common today. 110 extra_link_args += ['-lasound', '-ljack'] 111 112setup(name='PyAudio', 113 version=__version__, 114 author="Hubert Pham", 115 url="http://people.csail.mit.edu/hubert/pyaudio/", 116 description='PortAudio Python Bindings', 117 long_description=__doc__.lstrip(), 118 scripts=scripts, 119 py_modules=['pyaudio'], 120 package_dir={'': 'src'}, 121 ext_modules=[ 122 Extension('_portaudio', 123 sources=pyaudio_module_sources, 124 include_dirs=include_dirs, 125 define_macros=defines, 126 libraries=external_libraries, 127 extra_compile_args=extra_compile_args, 128 extra_link_args=extra_link_args) 129 ]) 130