From: Paul Brossier Date: Fri, 24 Mar 2017 03:22:51 +0000 (+0100) Subject: Merge branch 'aubiocmd' X-Git-Tag: 0.4.5~44 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=0561c54aa4e608447091a5aa1b32469227b22b84;hp=2615dd95a3f4c72249c0243eada6703d1eafd88c Merge branch 'aubiocmd' --- diff --git a/.gitignore b/.gitignore index f0d0dcac..16117274 100644 --- a/.gitignore +++ b/.gitignore @@ -38,8 +38,11 @@ python/MANIFEST python/*.db python/*.wav +pip-delete-this-directory.txt + aubio-*.tar.bz2 aubio-*.zip +dist/*.tar.gz # test sounds python/tests/sounds diff --git a/MANIFEST.in b/MANIFEST.in index c39c6d3e..745c1808 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include AUTHORS COPYING README.md VERSION ChangeLog include python/README.md +include this_version.py include Makefile wscript */wscript_build include waf waflib/* waflib/*/* exclude waflib/__pycache__/* diff --git a/README.md b/README.md index adaf1282..e13a62fc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ aubio library ============= +[![Travis build status](https://travis-ci.org/aubio/aubio.svg?branch=master)](https://travis-ci.org/aubio/aubio "Travis build status") +[![Appveyor build status](https://ci.appveyor.com/api/projects/status/f3lhy3a57rkgn5yi?svg=true)](https://ci.appveyor.com/project/aubio/aubio/branch/master "Appveyor build status") +[![Landscape code health](https://landscape.io/github/aubio/aubio/master/landscape.svg?style=flat)](https://landscape.io/github/aubio/aubio/master "Landscape code health") +[![Documentation Status](https://readthedocs.org/projects/aubio/badge/?version=latest)](http://aubio.readthedocs.io/en/latest/?badge=latest "Documentation status") +[![Commits since last release](https://img.shields.io/github/commits-since/aubio/aubio/0.4.4.svg?maxAge=2592000)](https://github.com/aubio/aubio "Commits since last release") aubio is a library to label music and sounds. It listens to audio signals and attempts to detect events. For instance, when a drum is hit, at which frequency diff --git a/doc/conf.py b/doc/conf.py index ad030c6a..e0f927c1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,6 +13,10 @@ import sys, os +# get version using this_version.py +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) +from this_version import get_aubio_version + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -48,9 +52,10 @@ copyright = u'2016, Paul Brossier' # built documents. # # The short X.Y version. -version = '0.4' + +version = get_aubio_version()[:3] # The full version, including alpha/beta/rc tags. -release = '0.4.5~alpha' +release = get_aubio_version() # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/python/lib/moresetuptools.py b/python/lib/moresetuptools.py index 08d51846..ee0f80aa 100644 --- a/python/lib/moresetuptools.py +++ b/python/lib/moresetuptools.py @@ -4,45 +4,7 @@ import sys, os, glob, subprocess import distutils, distutils.command.clean, distutils.dir_util from .gen_external import generate_external, header, output_path -def get_aubio_version(): - # read from VERSION - this_file_dir = os.path.dirname(os.path.abspath(__file__)) - version_file = os.path.join(this_file_dir, '..', '..', 'VERSION') - - if not os.path.isfile(version_file): - raise SystemError("VERSION file not found.") - - for l in open(version_file).readlines(): - #exec (l.strip()) - if l.startswith('AUBIO_MAJOR_VERSION'): - AUBIO_MAJOR_VERSION = int(l.split('=')[1]) - if l.startswith('AUBIO_MINOR_VERSION'): - AUBIO_MINOR_VERSION = int(l.split('=')[1]) - if l.startswith('AUBIO_PATCH_VERSION'): - AUBIO_PATCH_VERSION = int(l.split('=')[1]) - if l.startswith('AUBIO_VERSION_STATUS'): - AUBIO_VERSION_STATUS = l.split('=')[1].strip()[1:-1] - - if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \ - or AUBIO_PATCH_VERSION is None: - raise SystemError("Failed parsing VERSION file.") - - verstr = '.'.join(map(str, [AUBIO_MAJOR_VERSION, - AUBIO_MINOR_VERSION, - AUBIO_PATCH_VERSION])) - - if AUBIO_VERSION_STATUS is not None: - verstr += AUBIO_VERSION_STATUS - return verstr - -def get_aubio_pyversion(): - # convert to version for python according to pep 440 - # see https://www.python.org/dev/peps/pep-0440/ - verstr = get_aubio_version() - if '~alpha' in verstr: - verstr = verstr.split('~')[0] + 'a1' - # TODO: add rc, .dev, and .post suffixes, add numbering - return verstr +from this_version import get_aubio_version # inspired from https://gist.github.com/abergmeier/9488990 def add_packages(packages, ext=None, **kw): @@ -93,7 +55,7 @@ def add_local_aubio_lib(ext): ext.library_dirs += [os.path.join('build', 'src')] ext.libraries += ['aubio'] -def add_local_aubio_sources(ext, usedouble = False): +def add_local_aubio_sources(ext): """ build aubio inside python module instead of linking against libaubio """ print("Info: libaubio was not installed or built locally with waf, adding src/") aubio_sources = sorted(glob.glob(os.path.join('src', '**.c'))) @@ -101,6 +63,8 @@ def add_local_aubio_sources(ext, usedouble = False): ext.sources += aubio_sources def add_local_macros(ext, usedouble = False): + if usedouble: + ext.define_macros += [('HAVE_AUBIO_DOUBLE', 1)] # define macros (waf puts them in build/src/config.h) for define_macro in ['HAVE_STDLIB_H', 'HAVE_STDIO_H', 'HAVE_MATH_H', 'HAVE_STRING_H', @@ -193,7 +157,6 @@ class build_ext(_build_ext): def build_extension(self, extension): if self.enable_double or 'HAVE_AUBIO_DOUBLE' in os.environ: - extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)] enable_double = True else: enable_double = False @@ -204,7 +167,7 @@ class build_ext(_build_ext): # use local src/aubio.h if os.path.isfile(os.path.join('src', 'aubio.h')): add_local_aubio_header(extension) - add_local_macros(extension) + add_local_macros(extension, usedouble=enable_double) # look for a local waf build if os.path.isfile(os.path.join('build','src', 'fvec.c.1.o')): add_local_aubio_lib(extension) @@ -212,8 +175,9 @@ class build_ext(_build_ext): # check for external dependencies add_external_deps(extension, usedouble=enable_double) # add libaubio sources and look for optional deps with pkg-config - add_local_aubio_sources(extension, usedouble=enable_double) + add_local_aubio_sources(extension) # generate files python/gen/*.c, python/gen/aubio-generated.h + extension.include_dirs += [ output_path ] extension.sources += generate_external(header, output_path, overwrite = False, usedouble=enable_double) return _build_ext.build_extension(self, extension) diff --git a/python/tests/test_sink.py b/python/tests/test_sink.py index c31564a2..795032ba 100755 --- a/python/tests/test_sink.py +++ b/python/tests/test_sink.py @@ -117,10 +117,11 @@ class aubio_sink_test_case(TestCase): del_tmp_sink_path(sink_path) def test_read_with(self): - sink_path =get_tmp_sink_path() + samplerate = 44100 + sink_path = get_tmp_sink_path() vec = fvec(128) with sink(sink_path, samplerate) as g: - for i in range(10): + for _ in range(10): g(vec, 128) if __name__ == '__main__': diff --git a/python/tests/test_source.py b/python/tests/test_source.py index 755c01ed..d8809174 100755 --- a/python/tests/test_source.py +++ b/python/tests/test_source.py @@ -5,7 +5,6 @@ from nose2.tools import params from numpy.testing import TestCase, assert_equal from aubio import source from .utils import list_all_sounds -import numpy as np import warnings warnings.filterwarnings('ignore', category=UserWarning, append=True) diff --git a/setup.py b/setup.py index 987ff4cc..21bd495e 100755 --- a/setup.py +++ b/setup.py @@ -2,19 +2,19 @@ import sys, os.path, glob from setuptools import setup, Extension -from python.lib.moresetuptools import * +from python.lib.moresetuptools import build_ext, CleanGenerated # function to generate gen/*.{c,h} -from python.lib.gen_external import generate_external, header, output_path +from this_version import get_aubio_version, get_aubio_pyversion __version__ = get_aubio_pyversion() +__aubio_version__ = get_aubio_version() include_dirs = [] library_dirs = [] -define_macros = [('AUBIO_VERSION', '%s' % __version__)] +define_macros = [('AUBIO_VERSION', '%s' % __aubio_version__)] extra_link_args = [] include_dirs += [ 'python/ext' ] -include_dirs += [ output_path ] # aubio-generated.h try: import numpy include_dirs += [ numpy.get_include() ] diff --git a/this_version.py b/this_version.py new file mode 100644 index 00000000..4629f140 --- /dev/null +++ b/this_version.py @@ -0,0 +1,101 @@ +#! python +import os + +__version_info = {} # keep a reference to parse VERSION once + +def get_version_info(): + # read from VERSION + # return dictionary filled with content of version + if not __version_info: + this_file_dir = os.path.dirname(os.path.abspath(__file__)) + version_file = os.path.join(this_file_dir, 'VERSION') + + if not os.path.isfile(version_file): + raise SystemError("VERSION file not found.") + + for l in open(version_file).readlines(): + if l.startswith('AUBIO_MAJOR_VERSION'): + __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1]) + if l.startswith('AUBIO_MINOR_VERSION'): + __version_info['AUBIO_MINOR_VERSION'] = int(l.split('=')[1]) + if l.startswith('AUBIO_PATCH_VERSION'): + __version_info['AUBIO_PATCH_VERSION'] = int(l.split('=')[1]) + if l.startswith('AUBIO_VERSION_STATUS'): + __version_info['AUBIO_VERSION_STATUS'] = \ + l.split('=')[1].strip()[1:-1] + + if l.startswith('LIBAUBIO_LT_CUR'): + __version_info['LIBAUBIO_LT_CUR'] = int(l.split('=')[1]) + if l.startswith('LIBAUBIO_LT_REV'): + __version_info['LIBAUBIO_LT_REV'] = int(l.split('=')[1]) + if l.startswith('LIBAUBIO_LT_AGE'): + __version_info['LIBAUBIO_LT_AGE'] = int(l.split('=')[1]) + + if len(__version_info) < 6: + raise SystemError("Failed parsing VERSION file.") + + # switch version status with commit sha in alpha releases + if __version_info['AUBIO_VERSION_STATUS'] and \ + '~alpha' in __version_info['AUBIO_VERSION_STATUS']: + AUBIO_GIT_SHA = get_git_revision_hash() + if AUBIO_GIT_SHA: + __version_info['AUBIO_VERSION_STATUS'] = '~git+' + AUBIO_GIT_SHA + + return __version_info + +def get_libaubio_version(): + verfmt = '%(LIBAUBIO_LT_CUR)s.%(LIBAUBIO_LT_REV)s.%(LIBAUBIO_LT_AGE)s' + return str(verfmt % get_version_info()) + +def get_aubio_version(): + verfmt = '%(AUBIO_MAJOR_VERSION)s.%(AUBIO_MINOR_VERSION)s.%(AUBIO_PATCH_VERSION)s%(AUBIO_VERSION_STATUS)s' + return str(verfmt % get_version_info()) + +def get_aubio_pyversion(): + # convert to version for python according to pep 440 + # see https://www.python.org/dev/peps/pep-0440/ + # outputs MAJ.MIN.PATCH[a0[+git.[.mods]]] + aubio_version = get_aubio_version() + if '~git+' in aubio_version: + pep440str = aubio_version.replace('+', '.') + verstr = pep440str.replace('~git.', 'a0+') + elif '~alpha' in aubio_version: + verstr = aubio_version.replace('~alpha', 'a0') + else: + verstr = aubio_version + return verstr + +def get_git_revision_hash(short=True): + # get commit id, with +mods if local tree is not clean + if not os.path.isdir('.git'): + # print('Version : not in git repository : can\'t get sha') + return None + import subprocess + aubio_dir = os.path.dirname(os.path.abspath(__file__)) + if not os.path.exists(aubio_dir): + raise SystemError("git / root folder not found") + gitcmd = ['git', '-C', aubio_dir, 'rev-parse'] + if short: + gitcmd.append('--short') + gitcmd.append('HEAD') + try: + gitsha = subprocess.check_output(gitcmd).strip().decode('utf8') + except Exception as e: + print('git command error :%s' % e) + return None + # check if we have a clean tree + gitcmd = ['git', '-C', aubio_dir, 'status', '--porcelain'] + try: + output = subprocess.check_output(gitcmd).decode('utf8') + if len(output): + print('Info: current tree is not clean\n') + print(output) + gitsha += '+mods' + except subprocess.CalledProcessError as e: + print (e) + pass + return gitsha + +if __name__ == '__main__': + print ('%30s'% 'aubio version:', get_aubio_version()) + print ('%30s'% 'python-aubio version:', get_aubio_pyversion()) diff --git a/wscript b/wscript index 44021712..c9734573 100644 --- a/wscript +++ b/wscript @@ -14,19 +14,10 @@ import sys APPNAME = 'aubio' -# source VERSION -for l in open('VERSION').readlines(): exec (l.strip()) +from this_version import * -VERSION = '.'.join ([str(x) for x in [ - AUBIO_MAJOR_VERSION, - AUBIO_MINOR_VERSION, - AUBIO_PATCH_VERSION - ]]) + AUBIO_VERSION_STATUS - -LIB_VERSION = '.'.join ([str(x) for x in [ - LIBAUBIO_LT_CUR, - LIBAUBIO_LT_REV, - LIBAUBIO_LT_AGE]]) +VERSION = get_aubio_version() +LIB_VERSION = get_libaubio_version() top = '.' out = 'build' @@ -259,8 +250,8 @@ def configure(ctx): if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False): # one of fftwf or fftw3f if (ctx.options.enable_fftw3f != False): - ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', - args = '--cflags --libs', + ctx.check_cfg(package = 'fftw3f', + args = '--cflags --libs fftw3f >= 3.0.0', mandatory = ctx.options.enable_fftw3f) if (ctx.options.enable_double == True): ctx.msg('Warning', @@ -269,12 +260,12 @@ def configure(ctx): # fftw3f disabled, take most sensible one according to # enable_double if (ctx.options.enable_double == True): - ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', - args = '--cflags --libs', mandatory = - ctx.options.enable_fftw3) + ctx.check_cfg(package = 'fftw3', + args = '--cflags --libs fftw3 >= 3.0.0.', + mandatory = ctx.options.enable_fftw3) else: - ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', - args = '--cflags --libs', + ctx.check_cfg(package = 'fftw3f', + args = '--cflags --libs fftw3f >= 3.0.0', mandatory = ctx.options.enable_fftw3) ctx.define('HAVE_FFTW3', 1) @@ -290,8 +281,8 @@ def configure(ctx): # check for libsndfile if (ctx.options.enable_sndfile != False): - ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', - args = '--cflags --libs', + ctx.check_cfg(package = 'sndfile', + args = '--cflags --libs sndfile >= 1.0.4', mandatory = ctx.options.enable_sndfile) # check for libsamplerate @@ -303,8 +294,8 @@ def configure(ctx): ctx.msg('Checking if using samplerate', 'no (disabled in double precision mode)', color = 'YELLOW') if (ctx.options.enable_samplerate != False): - ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', - args = '--cflags --libs', + ctx.check_cfg(package = 'samplerate', + args = '--cflags --libs samplerate >= 0.0.15', mandatory = ctx.options.enable_samplerate) # check for jack @@ -315,21 +306,26 @@ def configure(ctx): # check for libav if (ctx.options.enable_avcodec != False): - ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0', - args = '--cflags --libs', uselib_store = 'AVCODEC', + ctx.check_cfg(package = 'libavcodec', + args = '--cflags --libs libavcodec >= 54.35.0', + uselib_store = 'AVCODEC', mandatory = ctx.options.enable_avcodec) - ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0', - args = '--cflags --libs', uselib_store = 'AVFORMAT', + ctx.check_cfg(package = 'libavformat', + args = '--cflags --libs libavformat >= 52.3.0', + uselib_store = 'AVFORMAT', mandatory = ctx.options.enable_avcodec) - ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0', - args = '--cflags --libs', uselib_store = 'AVUTIL', + ctx.check_cfg(package = 'libavutil', + args = '--cflags --libs libavutil >= 52.3.0', + uselib_store = 'AVUTIL', mandatory = ctx.options.enable_avcodec) - ctx.check_cfg(package = 'libswresample', atleast_version = '2.3.0', - args = '--cflags --libs', uselib_store = 'SWRESAMPLE', + ctx.check_cfg(package = 'libswresample', + args = '--cflags --libs libswresample >= 2.3.0', + uselib_store = 'SWRESAMPLE', mandatory = False) if 'HAVE_SWRESAMPLE' not in ctx.env: - ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1', - args = '--cflags --libs', uselib_store = 'AVRESAMPLE', + ctx.check_cfg(package = 'libavresample', + args = '--cflags --libs libavresample >= 1.0.1', + uselib_store = 'AVRESAMPLE', mandatory = False) msg_check = 'Checking for all libav libraries'