setup.py: clean-up, add option to build libaubio inside python-aubio
[aubio.git] / setup.py
1 #! /usr/bin/env python
2
3 import sys, os.path, glob
4 import numpy
5 from setuptools import setup, Extension
6 from python.lib.moresetuptools import *
7 # function to generate gen/*.{c,h}
8 from python.lib.gen_external import generate_external, header, output_path
9
10 # read from VERSION
11 for l in open('VERSION').readlines(): exec (l.strip())
12 __version__ = '.'.join \
13         ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
14         + AUBIO_VERSION_STATUS
15
16 include_dirs = []
17 library_dirs = []
18 define_macros = []
19 extra_link_args = []
20
21 include_dirs += [ 'python/ext' ]
22 include_dirs += [ output_path ] # aubio-generated.h
23 include_dirs += [ numpy.get_include() ]
24
25 if sys.platform.startswith('darwin'):
26     extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
27
28 sources = glob.glob(os.path.join('python', 'ext', '*.c'))
29
30 aubio_extension = Extension("aubio._aubio",
31     sources,
32     include_dirs = include_dirs,
33     library_dirs = library_dirs,
34     extra_link_args = extra_link_args,
35     define_macros = define_macros)
36
37 if os.path.isfile('src/aubio.h'):
38     # if aubio headers are found in this directory
39     add_local_aubio_header(aubio_extension)
40     # was waf used to build the shared lib?
41     if os.path.isdir(os.path.join('build','src')):
42         # link against build/src/libaubio, built with waf
43         add_local_aubio_lib(aubio_extension)
44     else:
45         # add libaubio sources and look for optional deps with pkg-config
46         add_local_aubio_sources(aubio_extension)
47         __version__ += '_libaubio'
48 else:
49     # look for aubio headers and lib using pkg-config
50     add_system_aubio(aubio_extension)
51
52
53 # generate files if they don't exit
54 aubio_extension.sources += generate_external(header, output_path, overwrite = False)
55
56 classifiers = [
57     'Development Status :: 4 - Beta',
58     'Environment :: Console',
59     'Intended Audience :: Science/Research',
60     'Topic :: Software Development :: Libraries',
61     'Topic :: Multimedia :: Sound/Audio :: Analysis',
62     'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis',
63     'Operating System :: POSIX',
64     'Operating System :: MacOS :: MacOS X',
65     'Operating System :: Microsoft :: Windows',
66     'Programming Language :: C',
67     'Programming Language :: Python',
68     'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
69     ]
70
71 distrib = setup(name='aubio',
72     version = __version__,
73     packages = ['aubio'],
74     package_dir = {'aubio':'python/lib/aubio'},
75     scripts = ['python/scripts/aubiocut'],
76     ext_modules = [aubio_extension],
77     description = 'interface to the aubio library',
78     long_description = 'interface to the aubio library',
79     license = 'GNU/GPL version 3',
80     author = 'Paul Brossier',
81     author_email = 'piem@aubio.org',
82     maintainer = 'Paul Brossier',
83     maintainer_email = 'piem@aubio.org',
84     url = 'http://aubio.org/',
85     platforms = 'any',
86     classifiers = classifiers,
87     install_requires = ['numpy'],
88     cmdclass = {
89         'clean': CleanGenerated,
90         'generate': GenerateCommand,
91         },
92     test_suite = 'nose2.collector.collector',
93     )