From f432bb1abed4352ebb2952f7d1aaa7b5443374e1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 21 Jan 2017 20:37:56 +0100 Subject: [PATCH] python/lib/moresetuptools.py: add get_aubio_version and get_aubio_pyversion --- python/lib/moresetuptools.py | 37 +++++++++++++++++++++++++++++++++++++ setup.py | 15 +-------------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/python/lib/moresetuptools.py b/python/lib/moresetuptools.py index 9765f5c8..583a6252 100644 --- a/python/lib/moresetuptools.py +++ b/python/lib/moresetuptools.py @@ -4,6 +4,43 @@ 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(): + verstr = get_aubio_version() + if '~alpha' in verstr: + verstr = verstr.split('~')[0] + 'a1' + 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 """ diff --git a/setup.py b/setup.py index 38be7c15..78ff7113 100755 --- a/setup.py +++ b/setup.py @@ -6,20 +6,7 @@ from python.lib.moresetuptools import * # 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()) - -if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \ - or AUBIO_PATCH_VERSION is None: - raise SystemError("Failed parsing VERSION file.") - -__version__ = '.'.join(map(str, [AUBIO_MAJOR_VERSION, - AUBIO_MINOR_VERSION, - AUBIO_PATCH_VERSION])) -if AUBIO_VERSION_STATUS is not None: - if AUBIO_VERSION_STATUS.startswith('~'): - AUBIO_VERSION_STATUS = AUBIO_VERSION_STATUS[1:] - #__version__ += AUBIO_VERSION_STATUS +__version__ = get_aubio_pyversion() include_dirs = [] library_dirs = [] -- 2.11.0