Index: python/lib/moresetuptools.py
===================================================================
--- python/lib/moresetuptools.py	(revision 115b4526f8875d3bbf6b419ddab940db5de249cc)
+++ python/lib/moresetuptools.py	(revision cc4987a7ce44a312272ed5e7eafcb1f71ac29b13)
@@ -56,5 +56,5 @@
     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/")
@@ -64,4 +64,6 @@
 
 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',
@@ -156,5 +158,4 @@
     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:
@@ -167,5 +168,5 @@
             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')):
@@ -175,5 +176,5 @@
                 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 ]
Index: python/tests/test_sink.py
===================================================================
--- python/tests/test_sink.py	(revision 115b4526f8875d3bbf6b419ddab940db5de249cc)
+++ python/tests/test_sink.py	(revision cc4987a7ce44a312272ed5e7eafcb1f71ac29b13)
@@ -118,8 +118,9 @@
 
     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)
 
Index: python/tests/test_source.py
===================================================================
--- python/tests/test_source.py	(revision 115b4526f8875d3bbf6b419ddab940db5de249cc)
+++ python/tests/test_source.py	(revision cc4987a7ce44a312272ed5e7eafcb1f71ac29b13)
@@ -6,5 +6,4 @@
 from aubio import source
 from .utils import list_all_sounds
-import numpy as np
 
 import warnings
Index: wscript
===================================================================
--- wscript	(revision 115b4526f8875d3bbf6b419ddab940db5de249cc)
+++ wscript	(revision cc4987a7ce44a312272ed5e7eafcb1f71ac29b13)
@@ -251,6 +251,6 @@
         # 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):
@@ -261,10 +261,10 @@
             # 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)
@@ -282,6 +282,6 @@
     # 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)
 
@@ -295,6 +295,6 @@
                     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)
 
@@ -307,19 +307,24 @@
     # 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)
 
