-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
117 lines (98 loc) · 3.25 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
#!/usr/bin/env python3
"""Klang installation script."""
import os
import sys
from setuptools import setup, find_packages, Extension
import numpy
import klang
INCLUDE_DIRS = ['/usr/local/include', '/usr/include', '/opt/include']
"""list: Include directories to check for library header files."""
def library_exists(library):
"""Check if C/C++ library is installed.
Args:
library (str): Header file to check.
Returns:
bool: Found library in INCLUDE_DIRS.
"""
for directory in INCLUDE_DIRS:
try:
if library in os.listdir(directory):
return True
except FileNotFoundError:
pass
return False
if sys.version_info < (3, 0):
raise SystemExit('Sorry, only Python 3 supported!')
if not library_exists('portaudio.h'):
fmt = ('Portaudio seems not to be installed! Looked in the following'
' directories:\n%s')
msg = fmt % '\n'.join(' ' + directory for directory in INCLUDE_DIRS)
raise SystemExit(msg)
with open('README.rst', 'r') as fh:
LONG_DESCRIPTION = fh.read()
KWARGS = dict(
author='Alexander Theler',
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: End Users/Desktop',
'Operating System :: MacOS',
'Operating System :: POSIX :: Linux',
'Operating System :: Unix',
'Programming Language :: C',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Multimedia :: Sound/Audio',
'Topic :: Multimedia :: Sound/Audio :: Editors',
'Topic :: Multimedia :: Sound/Audio :: MIDI',
'Topic :: Multimedia :: Sound/Audio :: Mixers',
'Topic :: Multimedia :: Sound/Audio :: Players',
'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis',
],
description='Block based synthesis and music library',
include_package_data=True,
install_requires=[
'numpy',
'scipy',
'matplotlib',
'PyAudio',
'pynput',
'samplerate',
'requests',
'beautifulsoup4',
'python-rtmidi',
],
keywords='synthesis music library',
long_description=LONG_DESCRIPTION,
long_description_content_type='text/x-rst',
name='klang',
package_data={
'klang.audio': ['samples/gong.wav'],
'klang.music': ['data/*.csv'],
},
packages=find_packages(),
python_requires='>=3.0', #TODO: ?
test_suite='tests',
url='https://github.com/atheler/klang',
version=klang.__version__,
)
if __name__ == '__main__':
try:
setup(ext_modules=[
Extension(
name='klang.audio._envelope',
sources=['klang/audio/_envelope.c'],
include_dirs=[numpy.get_include()],
),
Extension(
name='klang.audio._filters',
sources=['klang/audio/_filters.c'],
include_dirs=[numpy.get_include()],
),
], **KWARGS)
except SystemExit as err:
print(err)
print('Failed to built C-extensions. Continuing with pure Python fallback')
setup(**KWARGS)