[Meson] Refactor the logic that checks dependencies on numpy
authorWook Song <wook16.song@samsung.com>
Mon, 28 Oct 2019 01:17:53 +0000 (10:17 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 28 Oct 2019 11:40:47 +0000 (20:40 +0900)
This patch refactors the logic that checks dependencies on numpy.

Signed-off-by: Wook Song <wook16.song@samsung.com>
meson.build

index 7360b0c..ac106ab 100644 (file)
@@ -204,36 +204,30 @@ if get_option('enable-python')
   # Check python 2.7
   python2_dep = dependency('python-2.7', required: false)
   if python2_dep.found()
-    python2_incs = run_command(pg_pkgconfig, ['python-2.7', '--cflags']).stdout().strip().split()
+    python2_incs = []
+    python2_incs += run_command(pg_pkgconfig, ['python-2.7', '--cflags']).stdout().strip().split()
+    python2_incs += run_command('python2.7', ['-c', 'import site\nfor i in site.getsitepackages(): print("-I" + i + "/numpy/core/include")']).stdout().strip().split()
+    python2_incs += '-I' + run_command('python2.7', ['-m', 'site', '--user-site']).stdout().strip() + '/numpy/core/include'
     if cc.has_header('numpy/arrayobject.h', args: python2_incs)
       have_python2 = true
     else
-      python2_pkg_incs = run_command('python2.7', ['-c', 'import site\nfor i in site.getsitepackages(): print("-I" + i + "/numpy/core/include")']).stdout().strip().split()
-      python2_pkg_incs += '-I' + run_command('python2.7', ['-m', 'site', '--user-site']).stdout().strip() + '/numpy/core/include'
-      message('Numpy is not found in the default python include path. Searching for site/dist-packages include path...')
-      if cc.has_header('numpy/arrayobject.h', args: python2_pkg_incs)
-        have_python2 = true
-      else
-        message('Numpy is not found in both paths. NNStreamer-Python2.7 is disabled.')
-      endif
+      warning('Found python2.7, but failed to find numpy.')
+      warning('Disable nnstreamer-python2.')
     endif
   endif
 
   # Check python 3.x
   python3_dep = dependency('python3', required: false)
   if python3_dep.found()
-    python3_incs = run_command(pg_pkgconfig, ['python3', '--cflags']).stdout().strip().split()
+    python3_incs = []
+    python3_incs += run_command(pg_pkgconfig, ['python3', '--cflags']).stdout().strip().split()
+    python3_incs += run_command('python3', ['-c', 'import site\nfor i in site.getsitepackages(): print("-I" + i + "/numpy/core/include")']).stdout().strip().split()
+    python3_incs += '-I' + run_command('python3', ['-m', 'site', '--user-site']).stdout().strip() + '/numpy/core/include'
     if cc.has_header('numpy/arrayobject.h', args: python3_incs)
       have_python3 = true
     else
-      python3_pkg_incs = run_command('python3', ['-c', 'import site\nfor i in site.getsitepackages(): print("-I" + i + "/numpy/core/include")']).stdout().strip().split()
-      python3_pkg_incs += '-I' + run_command('python3', ['-m', 'site', '--user-site']).stdout().strip() + '/numpy/core/include'
-      message('Numpy is not found in the default python include path. Searching for site/dist-packages include path...')
-      if cc.has_header('numpy/arrayobject.h', args: python3_pkg_incs)
-        have_python3 = true
-      else
-        message('Numpy is not found in both paths. NNStreamer-Python3 is disabled.')
-      endif
+      warning('Found python3, but failed to find numpy.')
+      warning('Disable nnstreamer-python3.')
     endif
   endif
 endif