forked from echonest/remix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
172 lines (144 loc) · 5.84 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env python
__version__ = "2.2.1"
# Monkeypatch so that easy_install can install en-ffmpeg and youtube-dl
try:
from setuptools.sandbox import DirectorySandbox
def faux_violation(*args):
pass
DirectorySandbox._violation = faux_violation
except ImportError:
pass
import sys
import os
import glob
from distutils.core import setup, Extension
import numpy
def get_os():
"""returns is_linux, is_mac, is_windows"""
if hasattr(os, 'uname'):
if os.uname()[0] == "Darwin":
return False, True, False
return True, False, False
return False, False, True
is_linux, is_mac, is_windows = get_os()
def get_action():
cAction = os.path.join('external', 'cAction')
compile_args = [] if is_windows else ['-Wno-unused']
return Extension("cAction",
sources = [os.path.join(cAction, 'actionmodule.cpp')],
extra_compile_args = compile_args,
include_dirs = [numpy.get_include(), numpy.get_numarray_include()],
)
def get_dirac():
link_args = ['-framework', 'Carbon'] if is_mac else []
compile_args = [] if is_windows else ['-Wno-unused']
pydirac = os.path.join('external', 'pydirac225')
lib_sources = [os.path.join(pydirac, 'diracmodule.cpp'), os.path.join(pydirac, 'source', 'Dirac_LE.cpp')]
platform = os.uname()[0] if hasattr(os, 'uname') else 'Windows'
libname = 'Dirac64' if platform == 'Linux' and os.uname()[-1] == 'x86_64' else 'Dirac'
return Extension('dirac',
sources = lib_sources,
extra_compile_args = compile_args,
include_dirs = ['source', numpy.get_include(), numpy.get_numarray_include()],
libraries = [libname],
library_dirs = [os.path.join(pydirac, 'libs', platform)],
extra_link_args = link_args,
)
def get_soundtouch():
sources = ['AAFilter.cpp',
'FIFOSampleBuffer.cpp',
'FIRFilter.cpp',
'RateTransposer.cpp',
'SoundTouch.cpp',
'TDStretch.cpp',
'BPMDetect.cpp',
'PeakFinder.cpp',
'mmx_optimized.cpp',
'sse_optimized.cpp'
]
extra_compile_args = []
if is_linux or is_mac:
sources += ['cpu_detect_x86_gcc.cpp']
extra_compile_args = ['-O3', '-Wno-unused']
else:
sources += ['cpu_detect_x86_win.cpp', '3dnow_win.cpp']
pysoundtouch = os.path.join('external', 'pysoundtouch14', 'libsoundtouch')
lib_sources = [os.path.join(pysoundtouch, i) for i in sources]
lib_sources += [os.path.join('external', 'pysoundtouch14', 'soundtouchmodule.cpp')]
return Extension('soundtouch',
sources = lib_sources,
extra_compile_args = extra_compile_args,
include_dirs = [numpy.get_include(), numpy.get_numarray_include()]
)
all_data_files = []
if is_mac or is_linux:
# If we're in a virtualenv:
if 'real_prefix' in dir(sys):
data_path = os.path.join(sys.prefix, "local/bin")
else:
data_path = '/usr/local/bin'
if is_mac:
all_data_files = [(data_path, ['external/en-ffmpeg/mac/en-ffmpeg', 'external/youtube-dl/youtube-dl'])]
if is_linux:
all_data_files = [(data_path, ['external/youtube-dl/youtube-dl'])]
if is_windows:
all_data_files = [('.', ['external\\en-ffmpeg\\win\\en-ffmpeg.exe',
'external\\youtube-dl\\youtube-dl',
'external\\pydirac225\\libs\\Windows\\DiracLE.dll'])]
# Set the path to the examples:
if is_windows:
dest_prefix = 'echo-nest-remix-'
else:
# If we're in a virtualenv:
if 'real_prefix' in dir(sys):
dest_prefix = os.path.join(sys.prefix, "local/share/echo-nest-remix-")
else:
dest_prefix = '/usr/local/share/echo-nest-remix-'
for example_dir in glob.glob(os.path.join('examples', '*')):
example_files = glob.glob(os.path.join(example_dir, '*'))
actual_files = []
sub_path_tuples = []
for example_file in example_files:
files_within_example_file = glob.glob(os.path.join(example_file, '*'))
if not any(files_within_example_file):
actual_files.append(example_file)
else:
sub_path_tuples.append((dest_prefix + example_file, files_within_example_file))
all_data_files.append((dest_prefix + example_dir, actual_files))
if any(sub_path_tuples):
all_data_files.extend(sub_path_tuples)
setup(name='remix',
ext_modules = [get_soundtouch(), get_dirac(), get_action()],
version=__version__,
description='The internet synthesizer. Make things with music.',
author='The Echo Nest',
author_email='brian@echonest.com',
maintainer='Brian Whitman, Thor Kell',
maintainer_email='thor.kell@mail.mcgill.ca',
url='http://developer.echonest.com/',
download_url='http://static.echonest.com/remix/packages/remix-%s.tar.gz' % __version__,
license='New BSD',
data_files= all_data_files,
package_dir={'echonest':'src/echonest', 'pyechonest':'pyechonest/pyechonest'},
packages=['echonest', 'echonest.remix', 'echonest.remix.support', 'echonest.remix.support.midi', 'pyechonest'],
requires=['os',
'urllib',
'httplib',
'mimetypes',
'tempfile',
'commands',
'struct',
'wave',
'numpy',
'Numeric'
]
)
# Hack for pip install, to get correct permissions for en-ffmpeg and youtube-dl
try:
if is_mac:
os.chmod(os.path.join(data_path, 'en-ffmpeg'), 0755)
os.chmod(os.path.join(data_path, 'youtube-dl'), 0755)
if is_linux:
os.chmod(os.path.join(data_path, 'youtube-dl'), 0755)
except OSError:
pass