python/setup.py: remove unused import
[aubio.git] / python / setup.py
index 8c466b5..207ed90 100755 (executable)
@@ -1,6 +1,7 @@
-#! /usr/bin/python
+#! /usr/bin/env python
 
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
+from lib.moresetuptools import CleanGenerated, GenerateCommand
 
 import sys
 import os.path
@@ -12,30 +13,22 @@ __version__ = '.'.join \
         ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
         + AUBIO_VERSION_STATUS
 
+# function to generate gen/*.{c,h}
+from lib.gen_external import generate_external
+output_path = 'gen'
 
 include_dirs = []
 library_dirs = []
 define_macros = []
 extra_link_args = []
 
-include_dirs += ['ext']
+include_dirs += [ 'ext' ]
+include_dirs += [ output_path ] # aubio-generated.h
 include_dirs += [ numpy.get_include() ]
 
 if sys.platform.startswith('darwin'):
     extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
 
-output_path = 'gen'
-generated_object_files = []
-
-if not os.path.isdir(output_path):
-    from generator import generate_object_files
-    generated_object_files = generate_object_files(output_path)
-    # define include dirs
-else:
-    import glob
-    generated_object_files = glob.glob(os.path.join(output_path, '*.c'))
-include_dirs += [output_path]
-
 if os.path.isfile('../src/aubio.h'):
     define_macros += [('USE_LOCAL_AUBIO', 1)]
     include_dirs += ['../src'] # aubio.h
@@ -46,6 +39,7 @@ aubio_extension = Extension("aubio._aubio", [
     "ext/aubiomodule.c",
     "ext/aubioproxy.c",
     "ext/ufuncs.c",
+    "ext/py-musicutils.c",
     "ext/py-cvec.c",
     # example without macro
     "ext/py-filter.c",
@@ -53,8 +47,10 @@ aubio_extension = Extension("aubio._aubio", [
     "ext/py-filterbank.c",
     "ext/py-fft.c",
     "ext/py-phasevoc.c",
-    # generated files
-    ] + generated_object_files,
+    "ext/py-source.c",
+    "ext/py-sink.c",
+    # generate files if they don't exit
+    ] + generate_external(output_path, overwrite = False),
     include_dirs = include_dirs,
     library_dirs = library_dirs,
     extra_link_args = extra_link_args,
@@ -79,6 +75,8 @@ classifiers = [
 distrib = setup(name='aubio',
     version = __version__,
     packages = ['aubio'],
+    package_dir = {'aubio':'lib/aubio'},
+    scripts = ['scripts/aubiocut'],
     ext_modules = [aubio_extension],
     description = 'interface to the aubio library',
     long_description = 'interface to the aubio library',
@@ -90,4 +88,9 @@ distrib = setup(name='aubio',
     url = 'http://aubio.org/',
     platforms = 'any',
     classifiers = classifiers,
+    install_requires = ['numpy'],
+    cmdclass = {
+        'clean': CleanGenerated,
+        'generate': GenerateCommand,
+        }
     )