From ccbbd538d001ae4e17c86839b0583716e0dd3527 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 21 Jun 2020 18:50:55 +0200 Subject: [WIP] Add Python bindings --- bindings/python/meson.build | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 bindings/python/meson.build (limited to 'bindings/python/meson.build') 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 -- cgit v1.2.1