Showing the changes to python/setup.py (1 of 5 files). Show all
Unified · Split
| @@ -1,6 +1,7 @@ | |||
| 1 | #! /usr/bin/env python | 1 | #! /usr/bin/env python |
| 2 | 2 | ||
| 3 | from setuptools import setup, Extension | 3 | from setuptools import setup, Extension, Command |
| 4 | from lib.moresetuptools import CleanGenerated, GenerateCommand | ||
| 4 | 5 | ||
| 5 | import sys | 6 | import sys |
| 6 | import os.path | 7 | import os.path |
| @@ -12,30 +13,22 @@ __version__ = '.'.join \ · 5 unmodified lines | |||
| 12 | ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \ | 13 | ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \ |
| 13 | + AUBIO_VERSION_STATUS | 14 | + AUBIO_VERSION_STATUS |
| 14 | 15 | ||
| 16 | # function to generate gen/*.{c,h} | ||
| 17 | from lib.gen_external import generate_external | ||
| 18 | output_path = 'gen' | ||
| 15 | 19 | ||
| 16 | include_dirs = [] | 20 | include_dirs = [] |
| 17 | library_dirs = [] | 21 | library_dirs = [] |
| 18 | define_macros = [] | 22 | define_macros = [] |
| 19 | extra_link_args = [] | 23 | extra_link_args = [] |
| 20 | 24 | ||
| 21 | include_dirs += ['ext'] | 25 | include_dirs += [ 'ext' ] |
| 26 | include_dirs += [ output_path ] # aubio-generated.h | ||
| 22 | include_dirs += [ numpy.get_include() ] | 27 | include_dirs += [ numpy.get_include() ] |
| 23 | 28 | ||
| 24 | if sys.platform.startswith('darwin'): | 29 | if sys.platform.startswith('darwin'): |
| 25 | extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox'] | 30 | extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox'] |
| 26 | 31 | ||
| 27 | output_path = 'gen' | ||
| 28 | generated_object_files = [] | ||
| 29 | |||
| 30 | if not os.path.isdir(output_path): | ||
| 31 | from lib.gen_external import generate_external | ||
| 32 | generated_object_files = generate_external(output_path) | ||
| 33 | # define include dirs | ||
| 34 | else: | ||
| 35 | import glob | ||
| 36 | generated_object_files = glob.glob(os.path.join(output_path, '*.c')) | ||
| 37 | include_dirs += [output_path] | ||
| 38 | |||
| 39 | if os.path.isfile('../src/aubio.h'): | 32 | if os.path.isfile('../src/aubio.h'): |
| 40 | define_macros += [('USE_LOCAL_AUBIO', 1)] | 33 | define_macros += [('USE_LOCAL_AUBIO', 1)] |
| 41 | include_dirs += ['../src'] # aubio.h | 34 | include_dirs += ['../src'] # aubio.h |
| @@ -56,8 +49,8 @@ aubio_extension = Extension("aubio._aubio", [ · 14 unmodified lines | |||
| 56 | "ext/py-phasevoc.c", | 49 | "ext/py-phasevoc.c", |
| 57 | "ext/py-source.c", | 50 | "ext/py-source.c", |
| 58 | "ext/py-sink.c", | 51 | "ext/py-sink.c", |
| 59 | # generated files | 52 | # generate files if they don't exit |
| 60 | ] + generated_object_files, | 53 | ] + generate_external(output_path, overwrite = False), |
| 61 | include_dirs = include_dirs, | 54 | include_dirs = include_dirs, |
| 62 | library_dirs = library_dirs, | 55 | library_dirs = library_dirs, |
| 63 | extra_link_args = extra_link_args, | 56 | extra_link_args = extra_link_args, |
| @@ -96,4 +89,8 @@ distrib = setup(name='aubio', · 32 unmodified lines | |||
| 96 | platforms = 'any', | 89 | platforms = 'any', |
| 97 | classifiers = classifiers, | 90 | classifiers = classifiers, |
| 98 | install_requires = ['numpy'], | 91 | install_requires = ['numpy'], |
| 92 | cmdclass = { | ||
| 93 | 'clean': CleanGenerated, | ||
| 94 | 'generate': GenerateCommand, | ||
| 95 | } | ||
| 99 | ) | 96 | ) |