]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
pynvme: Make swig optional & python bindings conditional on swig
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Oct 2021 07:24:38 +0000 (15:24 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Oct 2021 08:21:25 +0000 (16:21 +0800)
We may not need have a python environment for some targets; make the
python bindings optional.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
pynvme/meson.build

index 15d5cc261ceebe4fbf144ba4df97a41429ed1b83..846e8e342165f474cd2c47fe2acd8a5ffc63f295 100644 (file)
@@ -6,28 +6,30 @@
 # Authors: Martin Belanger <Martin.Belanger@dell.com>
 #
 python3 = import('python').find_installation('python3')
-swig = find_program('swig', required: true)
-pymod_swig = custom_target(
-    'nvme.py',
-    input:   ['nvme.i', config_h],
-    output:  ['nvme.py', 'nvme_wrap.c'],
-    command: [swig, '-python', '-py3', '-o', '@OUTPUT1@', '@INPUT0@'],
-    install: true,
-    install_dir: [python3.get_install_dir(pure: false, subdir: 'libnvme'), false],
-)
+swig = find_program('swig', required: false)
+if swig.found()
+    pymod_swig = custom_target(
+        'nvme.py',
+        input:   ['nvme.i', config_h],
+        output:  ['nvme.py', 'nvme_wrap.c'],
+        command: [swig, '-python', '-py3', '-o', '@OUTPUT1@', '@INPUT0@'],
+        install: true,
+        install_dir: [python3.get_install_dir(pure: false, subdir: 'libnvme'), false],
+    )
 
-pynvme_clib = python3.extension_module(
-    '_nvme',
-    pymod_swig[1],
-    dependencies : python3.dependency(),
-    include_directories: incdir,
-    link_with: libnvme_static,
-    install: true,
-    subdir: 'libnvme',
-)
+    pynvme_clib = python3.extension_module(
+        '_nvme',
+        pymod_swig[1],
+        dependencies : python3.dependency(),
+        include_directories: incdir,
+        link_with: libnvme_static,
+        install: true,
+        subdir: 'libnvme',
+    )
 
-python3.install_sources(
-    ['__init__.py', ],
-    pure: false,
-    subdir: 'libnvme',
-)
+    python3.install_sources(
+        ['__init__.py', ],
+        pure: false,
+        subdir: 'libnvme',
+    )
+endif