aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/python/meson.build
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-06-21 18:50:55 +0200
committerDavid Robillard <d@drobilla.net>2022-01-28 22:21:07 -0500
commitccbbd538d001ae4e17c86839b0583716e0dd3527 (patch)
tree5d55f82f617171bb34199484c21f7ec6c50f28d9 /bindings/python/meson.build
parentcb9bc60bfd95173ead26540714dc682842cad80b (diff)
downloadserd-ccbbd538d001ae4e17c86839b0583716e0dd3527.tar.gz
serd-ccbbd538d001ae4e17c86839b0583716e0dd3527.tar.bz2
serd-ccbbd538d001ae4e17c86839b0583716e0dd3527.zip
[WIP] Add Python bindings
Diffstat (limited to 'bindings/python/meson.build')
-rw-r--r--bindings/python/meson.build71
1 files changed, 71 insertions, 0 deletions
diff --git a/bindings/python/meson.build b/bindings/python/meson.build
new file mode 100644
index 00000000..3a181870
--- /dev/null
+++ b/bindings/python/meson.build
@@ -0,0 +1,71 @@
+srcdir = meson.current_source_dir()
+blddir = meson.current_build_dir()
+
+if cc.get_id() == 'clang' or cc.get_id() == 'gcc'
+ cython_c_args = [
+ '-Wno-deprecated-declarations',
+ '-Wno-unused-variable',
+ ]
+endif
+
+# Generate extension module C source code with cython
+pyserd_c = custom_target(
+ 'serd.cpython.so',
+ command: [cython, '-3', '--fast-fail', '-Wextra', '@INPUT0@', '-o', '@OUTPUT@'],
+ input: ['serd.pyx'],
+ output: 'pyserd.c',
+ install: true,
+ install_dir: py.get_install_dir())
+
+# Compile extension module
+pyserd = py.extension_module('serd',
+ pyserd_c,
+ c_args: cython_c_args,
+ dependencies: [py_dep, serd_dep])
+
+# Set up an environment for loading the module from the build directory
+python_env = environment()
+python_env.set('PYTHONPATH', meson.current_build_dir())
+
+# Run API unit tests
+test('serd.pyx',
+ py,
+ args: ['-m', 'unittest', 'discover', '-b', '-v', srcdir],
+ env: python_env,
+ suite: ['bindings', 'python'])
+
+if sphinx_build.found()
+ # Test all code/output snippets in the documentation
+ test('doctest',
+ sphinx_build,
+ args: ['-W', '-b', 'doctest', srcdir, blddir],
+ env: python_env,
+ suite: ['bindings', 'python'])
+
+ if not get_option('docs').disabled()
+ py_html_docs = custom_target(
+ 'html documentation for serd python bindings',
+ command: [sphinx_build,
+ '-b', 'html', '-W', '-E', '-a', '-q', '-t', 'html',
+ srcdir, blddir],
+ input: [pyserd],
+ output: 'html',
+ build_by_default: true,
+ install: true,
+ install_dir: docdir / 'serd-0')
+
+ py_singlehtml_docs = custom_target(
+ 'singlehtml documentation for serd python bindings',
+ command: [sphinx_build,
+ '-b', 'singlehtml', '-W', '-E', '-a', '-q', '-t', 'singlehtml',
+ srcdir, blddir],
+ input: [pyserd],
+ output: 'singlehtml',
+ build_by_default: true,
+ install: true,
+ install_dir: docdir / 'serd-0')
+
+ # Copy static resources
+ subdir('_static')
+ endif
+endif