[9aa0af3] | 1 | #! /usr/bin/env python |
---|
[c71e405] | 2 | |
---|
[2675227] | 3 | import sys, os.path, glob |
---|
[1167631] | 4 | from setuptools import setup, Extension |
---|
[2675227] | 5 | from python.lib.moresetuptools import * |
---|
[1167631] | 6 | # function to generate gen/*.{c,h} |
---|
| 7 | from python.lib.gen_external import generate_external, header, output_path |
---|
[012b324] | 8 | |
---|
[945e26d] | 9 | # read from VERSION |
---|
[ad5203c] | 10 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
[416ddd1] | 11 | |
---|
| 12 | if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \ |
---|
| 13 | or AUBIO_PATCH_VERSION is None: |
---|
| 14 | raise SystemError("Failed parsing VERSION file.") |
---|
| 15 | |
---|
| 16 | __version__ = '.'.join(map(str, [AUBIO_MAJOR_VERSION, |
---|
| 17 | AUBIO_MINOR_VERSION, |
---|
| 18 | AUBIO_PATCH_VERSION])) |
---|
| 19 | if AUBIO_VERSION_STATUS is not None: |
---|
| 20 | if AUBIO_VERSION_STATUS.startswith('~'): |
---|
| 21 | AUBIO_VERSION_STATUS = AUBIO_VERSION_STATUS[1:] |
---|
| 22 | __version__ += AUBIO_VERSION_STATUS |
---|
[945e26d] | 23 | |
---|
[41399bd] | 24 | include_dirs = [] |
---|
| 25 | library_dirs = [] |
---|
| 26 | define_macros = [] |
---|
[4d3b573] | 27 | extra_link_args = [] |
---|
[012b324] | 28 | |
---|
[1167631] | 29 | include_dirs += [ 'python/ext' ] |
---|
[a89ed31] | 30 | include_dirs += [ output_path ] # aubio-generated.h |
---|
[5f6324e] | 31 | try: |
---|
| 32 | import numpy |
---|
| 33 | include_dirs += [ numpy.get_include() ] |
---|
| 34 | except ImportError: |
---|
| 35 | pass |
---|
[ad5203c] | 36 | |
---|
[4d3b573] | 37 | if sys.platform.startswith('darwin'): |
---|
| 38 | extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox'] |
---|
| 39 | |
---|
[2675227] | 40 | sources = glob.glob(os.path.join('python', 'ext', '*.c')) |
---|
| 41 | |
---|
| 42 | aubio_extension = Extension("aubio._aubio", |
---|
| 43 | sources, |
---|
[4d3b573] | 44 | include_dirs = include_dirs, |
---|
| 45 | library_dirs = library_dirs, |
---|
| 46 | extra_link_args = extra_link_args, |
---|
[2675227] | 47 | define_macros = define_macros) |
---|
| 48 | |
---|
| 49 | if os.path.isfile('src/aubio.h'): |
---|
| 50 | # if aubio headers are found in this directory |
---|
| 51 | add_local_aubio_header(aubio_extension) |
---|
| 52 | # was waf used to build the shared lib? |
---|
| 53 | if os.path.isdir(os.path.join('build','src')): |
---|
| 54 | # link against build/src/libaubio, built with waf |
---|
| 55 | add_local_aubio_lib(aubio_extension) |
---|
| 56 | else: |
---|
| 57 | # add libaubio sources and look for optional deps with pkg-config |
---|
| 58 | add_local_aubio_sources(aubio_extension) |
---|
| 59 | __version__ += '_libaubio' |
---|
| 60 | else: |
---|
| 61 | # look for aubio headers and lib using pkg-config |
---|
| 62 | add_system_aubio(aubio_extension) |
---|
| 63 | |
---|
| 64 | |
---|
[945e26d] | 65 | classifiers = [ |
---|
[4d3b573] | 66 | 'Development Status :: 4 - Beta', |
---|
| 67 | 'Environment :: Console', |
---|
| 68 | 'Intended Audience :: Science/Research', |
---|
| 69 | 'Topic :: Software Development :: Libraries', |
---|
| 70 | 'Topic :: Multimedia :: Sound/Audio :: Analysis', |
---|
| 71 | 'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis', |
---|
| 72 | 'Operating System :: POSIX', |
---|
| 73 | 'Operating System :: MacOS :: MacOS X', |
---|
| 74 | 'Operating System :: Microsoft :: Windows', |
---|
| 75 | 'Programming Language :: C', |
---|
| 76 | 'Programming Language :: Python', |
---|
| 77 | 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', |
---|
| 78 | ] |
---|
[012b324] | 79 | |
---|
[b1d37c0] | 80 | from distutils.command.build_ext import build_ext as _build_ext |
---|
| 81 | class build_ext(_build_ext): |
---|
| 82 | |
---|
| 83 | def build_extension(self, extension): |
---|
| 84 | # generate files python/gen/*.c, python/gen/aubio-generated.h |
---|
| 85 | extension.sources += generate_external(header, output_path, overwrite = False) |
---|
| 86 | return _build_ext.build_extension(self, extension) |
---|
| 87 | |
---|
[945e26d] | 88 | distrib = setup(name='aubio', |
---|
[4d3b573] | 89 | version = __version__, |
---|
| 90 | packages = ['aubio'], |
---|
[1167631] | 91 | package_dir = {'aubio':'python/lib/aubio'}, |
---|
| 92 | scripts = ['python/scripts/aubiocut'], |
---|
[4d3b573] | 93 | ext_modules = [aubio_extension], |
---|
[dc1fbc6] | 94 | description = 'a collection of tools for music analysis', |
---|
| 95 | long_description = 'a collection of tools for music analysis', |
---|
[4d3b573] | 96 | license = 'GNU/GPL version 3', |
---|
| 97 | author = 'Paul Brossier', |
---|
| 98 | author_email = 'piem@aubio.org', |
---|
| 99 | maintainer = 'Paul Brossier', |
---|
| 100 | maintainer_email = 'piem@aubio.org', |
---|
| 101 | url = 'http://aubio.org/', |
---|
| 102 | platforms = 'any', |
---|
| 103 | classifiers = classifiers, |
---|
[16f8dcc] | 104 | install_requires = ['numpy'], |
---|
[a89ed31] | 105 | cmdclass = { |
---|
| 106 | 'clean': CleanGenerated, |
---|
| 107 | 'generate': GenerateCommand, |
---|
[b1d37c0] | 108 | 'build_ext': build_ext, |
---|
[1167631] | 109 | }, |
---|
| 110 | test_suite = 'nose2.collector.collector', |
---|
[4d3b573] | 111 | ) |
---|