source: setup.py @ 2675227

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 2675227 was 2675227, checked in by Paul Brossier <piem@piem.org>, 8 years ago

setup.py: clean-up, add option to build libaubio inside python-aubio

The setup script now attempts to build the _aubio extension as follows:

  • if src/aubio.h is found, use it to generate python/gen/ files
  • if build/src/ is found, use it to link python-aubio against libaubio
  • otherwise:
    • add all libaubio source (src/*) to the python module sources
    • look for optional dependencies using pkg-config
    • set flags accordingly
  • otherwise, look for aubio headers and libraries using pkg-config

This should help building the python module in a virtualenv (#2),
on windows (#55), and allow installing aubio directly with pip.

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#! /usr/bin/env python
2
3import sys, os.path, glob
4import numpy
5from setuptools import setup, Extension
6from python.lib.moresetuptools import *
7# function to generate gen/*.{c,h}
8from python.lib.gen_external import generate_external, header, output_path
9
10# read from VERSION
11for 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
16include_dirs = []
17library_dirs = []
18define_macros = []
19extra_link_args = []
20
21include_dirs += [ 'python/ext' ]
22include_dirs += [ output_path ] # aubio-generated.h
23include_dirs += [ numpy.get_include() ]
24
25if sys.platform.startswith('darwin'):
26    extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
27
28sources = glob.glob(os.path.join('python', 'ext', '*.c'))
29
30aubio_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
37if 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'
48else:
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
54aubio_extension.sources += generate_external(header, output_path, overwrite = False)
55
56classifiers = [
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
71distrib = 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    )
Note: See TracBrowser for help on using the repository browser.