]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
Make Python Bindings optional
authorMartin Belanger <martin.belanger@dell.com>
Tue, 19 Oct 2021 18:34:03 +0000 (14:34 -0400)
committerMartin Belanger <martin.belanger@dell.com>
Tue, 19 Oct 2021 18:34:03 +0000 (14:34 -0400)
Added a new configuration parameter "python". By default it is set to 'auto',
which means that the Python bindings will be built if all dependencies can be
found on the host. If not, Python bindings won;t be built. The option can
also be set to 'true' or 'false' to force Python bindings to be built or not.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
meson_options.txt
pynvme/meson.build

index c83da2914d249b5736be99685ee698f97e3c170a..e87ad76503ea563fb416c292ccacac27588f6e3e 100644 (file)
@@ -3,3 +3,4 @@
 option('pkgconfiglibdir', type : 'string', value : '', description : 'directory for standard pkg-config files')
 
 option('man', type : 'boolean', value : false, description : 'build and install man pages (requires sphinx-build)')
+option('python', type : 'combo', choices : ['auto', 'true', 'false'], description : 'Generate libnvme python bindings')
index 5e9c96d45046a117b1bdecfebf357f1dcb485b3d..bde1536befba56ecc700e228af9df16b5a8869d5 100644 (file)
@@ -5,9 +5,18 @@
 #
 # Authors: Martin Belanger <Martin.Belanger@dell.com>
 #
-python3 = import('python').find_installation('python3')
-swig = find_program('swig', required: false)
-if swig.found()
+
+want_python = get_option('python')
+if want_python != 'false'
+    python3 = import('python').find_installation('python3')
+    py3_dep = python3.dependency(required: want_python == 'true')
+    swig = find_program('swig', required: want_python == 'true')
+    have_python_support = py3_dep.found() and swig.found()
+else
+    have_python_support = false
+endif
+
+if have_python_support
     pymod_swig = custom_target(
         'nvme.py',
         input:   ['nvme.i', config_h],
@@ -20,7 +29,7 @@ if swig.found()
     pynvme_clib = python3.extension_module(
         '_nvme',
         pymod_swig[1],
-        dependencies : python3.dependency(),
+        dependencies : py3_dep,
         include_directories: incdir,
         link_with: libnvme,
         install: true,