ref: 1167631cbafc6fa1cbc277c7f9c195d47b08b72d
parent: c09efcaa6cbfc971096cd8ef40bf2726f42d3638
author: Paul Brossier <piem@piem.org>
date: Fri May 13 14:50:20 EDT 2016
move python/setup.py to setup.py, update Makefile, add requirements
--- a/Makefile
+++ b/Makefile
@@ -28,27 +28,32 @@
$(WAFCMD) build $(WAFOPTS)
build_python:
- cd python && python ./setup.py generate $(ENABLE_DOUBLE) build
+ python ./setup.py generate $(ENABLE_DOUBLE) build
+test_python: export LD_LIBRARY_PATH=$(PWD)/build/src
test_python:
- cd python && pip install -v .
- cd python && LD_LIBRARY_PATH=$(PWD)/build/src nose2 --verbose
- cd python && pip uninstall -y -v aubio
+ pip install -v -r requirements.txt
+ pip install -v .
+ nose2 --verbose
+ pip uninstall -y -v aubio
test_python_osx:
- cd python && pip install --user -v .
+ # create links from ~/lib/lib* to build/src/lib*
[ -f build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.4.dylib ~/lib ) || true
- cd python && nose2 --verbose
- cd python && pip uninstall -y -v aubio
+ # then run the tests
+ pip install --user -v -r requirements.txt
+ pip install --user -v .
+ nose2 --verbose
+ pip uninstall -y -v aubio
clean_python:
- cd python && ./setup.py clean
+ ./setup.py clean
build_python3:
- cd python && python3 ./setup.py generate $(ENABLE_DOUBLE) build
+ python3 ./setup.py generate $(ENABLE_DOUBLE) build
clean_python3:
- cd python && python3 ./setup.py clean
+ python3 ./setup.py clean
clean:
$(WAFCMD) clean
--- /dev/null
+++ b/nose2.cfg
@@ -1,0 +1,6 @@
+[unittest]
+start-dir = python/tests/
+plugins = nose2.plugins.mp
+
+[multiprocess]
+always-on = true
--- a/python/lib/gen_external.py
+++ b/python/lib/gen_external.py
@@ -1,6 +1,9 @@
import os, glob
-header = """// this file is generated! do not modify
+header = 'src/aubio.h'
+output_path = 'python/gen'
+
+source_header = """// this file is generated! do not modify
#include "aubio-types.h"
"""
@@ -41,9 +44,9 @@
]
-def get_cpp_objects():
+def get_cpp_objects(header=header):
- cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=1 -I../build/src ../src/aubio.h').readlines()]
+ cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=1 {:s}'.format(header)).readlines()]
#cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/onset/onset.h').readlines()]
#cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/pitch/pitch.h').readlines()]
@@ -66,11 +69,11 @@
return cpp_output, cpp_objects
-def generate_external(output_path, usedouble = False, overwrite = True):
+def generate_external(header=header, output_path=output_path, usedouble=False, overwrite=True):
if not os.path.isdir(output_path): os.mkdir(output_path)
elif overwrite == False: return glob.glob(os.path.join(output_path, '*.c'))
sources_list = []
- cpp_output, cpp_objects = get_cpp_objects()
+ cpp_output, cpp_objects = get_cpp_objects(header)
lib = {}
for o in cpp_objects:
@@ -121,9 +124,12 @@
print ( "{:15s} {:10s} {:d}".format(o, family, len(lib[o][family]) ) )
"""
- from .gen_code import MappedObject
+ try:
+ from .gen_code import MappedObject
+ except (SystemError, ValueError) as e:
+ from gen_code import MappedObject
for o in lib:
- out = header
+ out = source_header
mapped = MappedObject(lib[o], usedouble = usedouble)
out += mapped.gen_code()
output_file = os.path.join(output_path, 'gen-%s.c' % o)
@@ -132,7 +138,7 @@
print ("wrote %s" % output_file )
sources_list.append(output_file)
- out = header
+ out = source_header
out += "#include \"aubio-generated.h\""
check_types = "\n || ".join(["PyType_Ready(&Py_%sType) < 0" % o for o in lib])
out += """
@@ -186,5 +192,7 @@
return sources_list
if __name__ == '__main__':
- output_path = 'gen'
- generate_external(output_path)
+ import sys
+ if len(sys.argv) > 1: header = sys.argv[1]
+ if len(sys.argv) > 2: output_path = sys.argv[2]
+ generate_external(header, output_path)
--- a/python/lib/moresetuptools.py
+++ b/python/lib/moresetuptools.py
@@ -1,8 +1,9 @@
import distutils, distutils.command.clean, distutils.dir_util
+from .gen_external import generate_external, header, output_path
class CleanGenerated(distutils.command.clean.clean):
def run(self):
- distutils.dir_util.remove_tree('gen')
+ distutils.dir_util.remove_tree(output_path)
distutils.command.clean.clean.run(self)
class GenerateCommand(distutils.cmd.Command):
@@ -23,5 +24,4 @@
def run(self):
self.announce( 'Generating code', level=distutils.log.INFO)
- from .gen_external import generate_external
- generated_object_files = generate_external('gen', usedouble = self.enable_double)
+ generated_object_files = generate_external(header, output_path, usedouble = self.enable_double)
--- a/python/nose2.cfg
+++ /dev/null
@@ -1,6 +1,0 @@
-[unittest]
-start-dir = tests/
-plugins = nose2.plugins.mp
-
-[multiprocess]
-always-on = true
--- a/python/setup.py
+++ /dev/null
@@ -1,95 +1,0 @@
-#! /usr/bin/env python
-
-from setuptools import setup, Extension
-from lib.moresetuptools import CleanGenerated, GenerateCommand
-
-import sys
-import os.path
-import numpy
-
-# read from VERSION
-for l in open('VERSION').readlines(): exec (l.strip())
-__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 += [ output_path ] # aubio-generated.h
-include_dirs += [ numpy.get_include() ]
-
-if sys.platform.startswith('darwin'):
- extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
-
-if os.path.isfile('../src/aubio.h'):
- define_macros += [('USE_LOCAL_AUBIO', 1)]
- include_dirs += ['../src'] # aubio.h
- library_dirs += ['../build/src']
-
-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",
- # macroised
- "ext/py-filterbank.c",
- "ext/py-fft.c",
- "ext/py-phasevoc.c",
- "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,
- define_macros = define_macros,
- libraries=['aubio'])
-
-classifiers = [
- 'Development Status :: 4 - Beta',
- 'Environment :: Console',
- 'Intended Audience :: Science/Research',
- 'Topic :: Software Development :: Libraries',
- 'Topic :: Multimedia :: Sound/Audio :: Analysis',
- 'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis',
- 'Operating System :: POSIX',
- 'Operating System :: MacOS :: MacOS X',
- 'Operating System :: Microsoft :: Windows',
- 'Programming Language :: C',
- 'Programming Language :: Python',
- 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
- ]
-
-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',
- license = 'GNU/GPL version 3',
- author = 'Paul Brossier',
- author_email = 'piem@aubio.org',
- maintainer = 'Paul Brossier',
- maintainer_email = 'piem@aubio.org',
- url = 'http://aubio.org/',
- platforms = 'any',
- classifiers = classifiers,
- install_requires = ['numpy'],
- cmdclass = {
- 'clean': CleanGenerated,
- 'generate': GenerateCommand,
- }
- )
--- /dev/null
+++ b/requirements.txt
@@ -1,0 +1,2 @@
+numpy
+nose2
--- /dev/null
+++ b/setup.py
@@ -1,0 +1,91 @@
+#! /usr/bin/env python
+
+import sys
+import os.path
+import numpy
+from setuptools import setup, Extension
+from python.lib.moresetuptools import CleanGenerated, GenerateCommand
+# function to generate gen/*.{c,h}
+from python.lib.gen_external import generate_external, header, output_path
+
+# read from VERSION
+for l in open('VERSION').readlines(): exec (l.strip())
+__version__ = '.'.join \
+ ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
+ + AUBIO_VERSION_STATUS
+
+include_dirs = []
+library_dirs = []
+define_macros = []
+extra_link_args = []
+
+include_dirs += [ 'python/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']
+
+if os.path.isfile('src/aubio.h'):
+ define_macros += [('USE_LOCAL_AUBIO', 1)]
+ include_dirs += ['src'] # aubio.h
+ library_dirs += ['build/src']
+
+aubio_extension = Extension("aubio._aubio", [
+ "python/ext/aubiomodule.c",
+ "python/ext/aubioproxy.c",
+ "python/ext/ufuncs.c",
+ "python/ext/py-musicutils.c",
+ "python/ext/py-cvec.c",
+ "python/ext/py-filter.c",
+ "python/ext/py-filterbank.c",
+ "python/ext/py-fft.c",
+ "python/ext/py-phasevoc.c",
+ "python/ext/py-source.c",
+ "python/ext/py-sink.c",
+ # generate files if they don't exit
+ ] + generate_external(header, output_path, overwrite = False),
+ include_dirs = include_dirs,
+ library_dirs = library_dirs,
+ extra_link_args = extra_link_args,
+ define_macros = define_macros,
+ libraries=['aubio'])
+
+classifiers = [
+ 'Development Status :: 4 - Beta',
+ 'Environment :: Console',
+ 'Intended Audience :: Science/Research',
+ 'Topic :: Software Development :: Libraries',
+ 'Topic :: Multimedia :: Sound/Audio :: Analysis',
+ 'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis',
+ 'Operating System :: POSIX',
+ 'Operating System :: MacOS :: MacOS X',
+ 'Operating System :: Microsoft :: Windows',
+ 'Programming Language :: C',
+ 'Programming Language :: Python',
+ 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
+ ]
+
+distrib = setup(name='aubio',
+ version = __version__,
+ packages = ['aubio'],
+ package_dir = {'aubio':'python/lib/aubio'},
+ scripts = ['python/scripts/aubiocut'],
+ ext_modules = [aubio_extension],
+ description = 'interface to the aubio library',
+ long_description = 'interface to the aubio library',
+ license = 'GNU/GPL version 3',
+ author = 'Paul Brossier',
+ author_email = 'piem@aubio.org',
+ maintainer = 'Paul Brossier',
+ maintainer_email = 'piem@aubio.org',
+ url = 'http://aubio.org/',
+ platforms = 'any',
+ classifiers = classifiers,
+ install_requires = ['numpy'],
+ cmdclass = {
+ 'clean': CleanGenerated,
+ 'generate': GenerateCommand,
+ },
+ test_suite = 'nose2.collector.collector',
+ )