forked from kivy/audiostream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
105 lines (93 loc) · 3.18 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import sys
import os
from os.path import join, dirname
from os import environ
from distutils.core import setup
from distutils.extension import Extension
# detect Python for android project (http://github.com/kivy/python-for-android)
# or kivy-ios (http://github.com/kivy/kivy-ios)
platform = sys.platform
ndkplatform = environ.get('NDKPLATFORM')
if ndkplatform is not None and environ.get('LIBLINK'):
platform = 'android'
kivy_ios_root = environ.get('KIVYIOSROOT', None)
if kivy_ios_root is not None:
platform = 'ios'
# ensure Cython is installed for desktop app
have_cython = False
cmdclass = {}
if platform in ('android', 'ios'):
print 'Cython import ignored'
else:
try:
from Cython.Distutils import build_ext
have_cython = True
cmdclass['build_ext'] = build_ext
except ImportError:
print '**** Cython is required to compile audiostream ****'
raise
# configure the env
libraries = ['SDL', 'SDL_mixer']
library_dirs = []
include_dirs = ['/usr/include/SDL']
extra_objects = []
extra_compile_args =['-ggdb', '-O2']
extra_link_args = []
extensions = []
if not have_cython:
libraries = ['sdl', 'sdl_mixer']
else:
include_dirs.append('.')
include_dirs.append('/usr/include/SDL')
# generate an Extension object from its dotted name
def makeExtension(extName, files=None):
extPath = extName.replace('.', os.path.sep) + (
'.c' if not have_cython else '.pyx')
if files is None:
files = []
return Extension(
extName,
[extPath] + files,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_objects=extra_objects,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
if platform == 'android':
extensions.append(makeExtension('audiostream.platform.plat_android'))
elif platform == 'ios':
include_dirs = [
join(kivy_ios_root, 'build', 'include'),
join(kivy_ios_root, 'build', 'include', 'SDL')]
extra_link_args = [
'-L', join(kivy_ios_root, 'build', 'lib'),
'-undefined', 'dynamic_lookup']
extensions.append(makeExtension('audiostream.platform.plat_ios',
[join('audiostream', 'platform', 'ios_ext.m')]))
elif platform == "darwin":
include_dirs.append('/usr/local/include/SDL')
extensions.append(makeExtension('audiostream.platform.plat_mac',
[join('audiostream', 'platform', 'mac_ext.m')]))
config_pxi = join(dirname(__file__), 'audiostream', 'config.pxi')
with open(config_pxi, 'w') as fd:
fd.write('DEF PLATFORM = "{}"'.format(platform))
# indicate which extensions we want to compile
extensions += [makeExtension(x) for x in (
'audiostream.sources.thread',
'audiostream.sources.wave',
'audiostream.sources.puredata',
'audiostream.core')]
setup(
name='audiostream',
version='0.2dev',
author='Mathieu Virbel, Dustin Lacewell',
author_email='[email protected]',
packages=['audiostream', 'audiostream.sources', 'audiostream.platform'],
url='http://txzone.net/',
license='LGPL',
description='An audio library designed to let the user stream to speakers',
ext_modules=extensions,
cmdclass=cmdclass,
)