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):
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')))
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',
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
# 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)
# 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)
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'
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',
# 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)
# 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
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
# 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'