1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | import sys, os.path, glob |
---|
4 | from setuptools import setup, Extension |
---|
5 | from python.lib.moresetuptools import * |
---|
6 | # function to generate gen/*.{c,h} |
---|
7 | from python.lib.gen_external import generate_external, header, output_path |
---|
8 | |
---|
9 | # read from VERSION |
---|
10 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
11 | __version__ = '.'.join \ |
---|
12 | ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \ |
---|
13 | + AUBIO_VERSION_STATUS |
---|
14 | |
---|
15 | include_dirs = [] |
---|
16 | library_dirs = [] |
---|
17 | define_macros = [] |
---|
18 | extra_link_args = [] |
---|
19 | |
---|
20 | include_dirs += [ 'python/ext' ] |
---|
21 | include_dirs += [ output_path ] # aubio-generated.h |
---|
22 | try: |
---|
23 | import numpy |
---|
24 | include_dirs += [ numpy.get_include() ] |
---|
25 | except ImportError: |
---|
26 | pass |
---|
27 | |
---|
28 | if sys.platform.startswith('darwin'): |
---|
29 | extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox'] |
---|
30 | |
---|
31 | sources = glob.glob(os.path.join('python', 'ext', '*.c')) |
---|
32 | |
---|
33 | aubio_extension = Extension("aubio._aubio", |
---|
34 | sources, |
---|
35 | include_dirs = include_dirs, |
---|
36 | library_dirs = library_dirs, |
---|
37 | extra_link_args = extra_link_args, |
---|
38 | define_macros = define_macros) |
---|
39 | |
---|
40 | if os.path.isfile('src/aubio.h'): |
---|
41 | # if aubio headers are found in this directory |
---|
42 | add_local_aubio_header(aubio_extension) |
---|
43 | # was waf used to build the shared lib? |
---|
44 | if os.path.isdir(os.path.join('build','src')): |
---|
45 | # link against build/src/libaubio, built with waf |
---|
46 | add_local_aubio_lib(aubio_extension) |
---|
47 | else: |
---|
48 | # add libaubio sources and look for optional deps with pkg-config |
---|
49 | add_local_aubio_sources(aubio_extension) |
---|
50 | __version__ += '_libaubio' |
---|
51 | else: |
---|
52 | # look for aubio headers and lib using pkg-config |
---|
53 | add_system_aubio(aubio_extension) |
---|
54 | |
---|
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 | from distutils.command.build_ext import build_ext as _build_ext |
---|
72 | class build_ext(_build_ext): |
---|
73 | |
---|
74 | def build_extension(self, extension): |
---|
75 | # generate files python/gen/*.c, python/gen/aubio-generated.h |
---|
76 | extension.sources += generate_external(header, output_path, overwrite = False) |
---|
77 | return _build_ext.build_extension(self, extension) |
---|
78 | |
---|
79 | distrib = setup(name='aubio', |
---|
80 | version = __version__, |
---|
81 | packages = ['aubio'], |
---|
82 | package_dir = {'aubio':'python/lib/aubio'}, |
---|
83 | scripts = ['python/scripts/aubiocut'], |
---|
84 | ext_modules = [aubio_extension], |
---|
85 | description = 'interface to the aubio library', |
---|
86 | long_description = 'interface to the aubio library', |
---|
87 | license = 'GNU/GPL version 3', |
---|
88 | author = 'Paul Brossier', |
---|
89 | author_email = 'piem@aubio.org', |
---|
90 | maintainer = 'Paul Brossier', |
---|
91 | maintainer_email = 'piem@aubio.org', |
---|
92 | url = 'http://aubio.org/', |
---|
93 | platforms = 'any', |
---|
94 | classifiers = classifiers, |
---|
95 | install_requires = ['numpy'], |
---|
96 | cmdclass = { |
---|
97 | 'clean': CleanGenerated, |
---|
98 | 'generate': GenerateCommand, |
---|
99 | 'build_ext': build_ext, |
---|
100 | }, |
---|
101 | test_suite = 'nose2.collector.collector', |
---|
102 | ) |
---|