ref: cc4987a7ce44a312272ed5e7eafcb1f71ac29b13
parent: 6448d31a699c3233e2e90cf2dc2734dd86e98ead
parent: 115b4526f8875d3bbf6b419ddab940db5de249cc
author: Paul Brossier <piem@piem.org>
date: Fri Mar 24 00:22:42 EDT 2017
Merge branch 'gitshaversion'
--- a/.gitignore
+++ b/.gitignore
@@ -38,8 +38,11 @@
python/*.db
python/*.wav
+pip-delete-this-directory.txt
+
aubio-*.tar.bz2
aubio-*.zip
+dist/*.tar.gz
# test sounds
python/tests/sounds
--- 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__/*
--- 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
--- 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 @@
# 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.
--- a/python/lib/moresetuptools.py
+++ b/python/lib/moresetuptools.py
@@ -4,46 +4,8 @@
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')
+from this_version import get_aubio_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
-
# inspired from https://gist.github.com/abergmeier/9488990
def add_packages(packages, ext=None, **kw):
""" use pkg-config to search which of 'packages' are installed """
@@ -215,6 +177,7 @@
# add libaubio sources and look for optional deps with pkg-config
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)
--- 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() ]
--- /dev/null
+++ b/this_version.py
@@ -1,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.<sha>[.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())
--- a/wscript
+++ b/wscript
@@ -14,19 +14,10 @@
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'