From f413c2eaebcddeff5f5f228a4dbabb1e54d34893 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 17 Aug 2021 16:25:22 -0400 Subject: tests: python module should install files correctly - default to python site-packages - subdir to site-packages/subdir - arbitrary install_dir --- test cases/python/2 extmodule/blaster.py | 11 ----------- test cases/python/2 extmodule/blaster.py.in | 11 +++++++++++ test cases/python/2 extmodule/ext/meson.build | 4 ++++ test cases/python/2 extmodule/ext/nested/meson.build | 15 +++++++++++++++ test cases/python/2 extmodule/ext/tachyon_module.c | 2 +- test cases/python/2 extmodule/ext/wrongdir/meson.build | 7 +++++++ test cases/python/2 extmodule/meson.build | 10 +++++++++- test cases/python/2 extmodule/test.json | 13 +++++++++++++ 8 files changed, 60 insertions(+), 13 deletions(-) delete mode 100755 test cases/python/2 extmodule/blaster.py create mode 100755 test cases/python/2 extmodule/blaster.py.in create mode 100644 test cases/python/2 extmodule/ext/nested/meson.build create mode 100644 test cases/python/2 extmodule/ext/wrongdir/meson.build create mode 100644 test cases/python/2 extmodule/test.json diff --git a/test cases/python/2 extmodule/blaster.py b/test cases/python/2 extmodule/blaster.py deleted file mode 100755 index aaac984..0000000 --- a/test cases/python/2 extmodule/blaster.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 - -import tachyon - -result = tachyon.phaserize('shoot') - -if not isinstance(result, int): - raise SystemExit('Returned result not an integer.') - -if result != 1: - raise SystemExit(f'Returned result {result} is not 1.') diff --git a/test cases/python/2 extmodule/blaster.py.in b/test cases/python/2 extmodule/blaster.py.in new file mode 100755 index 0000000..b690b40 --- /dev/null +++ b/test cases/python/2 extmodule/blaster.py.in @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import @tachyon_module@ as tachyon + +result = tachyon.phaserize('shoot') + +if not isinstance(result, int): + raise SystemExit('Returned result not an integer.') + +if result != 1: + raise SystemExit(f'Returned result {result} is not 1.') diff --git a/test cases/python/2 extmodule/ext/meson.build b/test cases/python/2 extmodule/ext/meson.build index b13bb32..799e9b0 100644 --- a/test cases/python/2 extmodule/ext/meson.build +++ b/test cases/python/2 extmodule/ext/meson.build @@ -1,6 +1,10 @@ pylib = py.extension_module('tachyon', 'tachyon_module.c', dependencies : py_dep, + c_args: '-DMESON_MODULENAME="tachyon"', + install: true, ) +subdir('nested') +subdir('wrongdir') pypathdir = meson.current_build_dir() diff --git a/test cases/python/2 extmodule/ext/nested/meson.build b/test cases/python/2 extmodule/ext/nested/meson.build new file mode 100644 index 0000000..044ddf4 --- /dev/null +++ b/test cases/python/2 extmodule/ext/nested/meson.build @@ -0,0 +1,15 @@ +py.extension_module('tachyon', + '../tachyon_module.c', + dependencies : py_dep, + c_args: '-DMESON_MODULENAME="nested.tachyon"', + install: true, + subdir: 'nested' +) +py.install_sources( + configure_file( + input: '../../blaster.py.in', + output: 'blaster.py', + configuration: {'tachyon_module': 'nested.tachyon'} + ), + subdir: 'nested', +) diff --git a/test cases/python/2 extmodule/ext/tachyon_module.c b/test cases/python/2 extmodule/ext/tachyon_module.c index b2592e4..a5d7cdc 100644 --- a/test cases/python/2 extmodule/ext/tachyon_module.c +++ b/test cases/python/2 extmodule/ext/tachyon_module.c @@ -38,7 +38,7 @@ static PyMethodDef TachyonMethods[] = { static struct PyModuleDef tachyonmodule = { PyModuleDef_HEAD_INIT, - "tachyon", + MESON_MODULENAME, NULL, -1, TachyonMethods diff --git a/test cases/python/2 extmodule/ext/wrongdir/meson.build b/test cases/python/2 extmodule/ext/wrongdir/meson.build new file mode 100644 index 0000000..1355d4f --- /dev/null +++ b/test cases/python/2 extmodule/ext/wrongdir/meson.build @@ -0,0 +1,7 @@ +py.extension_module('tachyon', + '../tachyon_module.c', + dependencies : py_dep, + c_args: '-DMESON_MODULENAME="tachyon"', + install: true, + install_dir: get_option('libdir') +) diff --git a/test cases/python/2 extmodule/meson.build b/test cases/python/2 extmodule/meson.build index 18d70c8..7362de3 100644 --- a/test cases/python/2 extmodule/meson.build +++ b/test cases/python/2 extmodule/meson.build @@ -18,11 +18,19 @@ endif subdir('ext') +blaster = configure_file( + input: 'blaster.py.in', + output: 'blaster.py', + configuration: {'tachyon_module': 'tachyon'} +) + test('extmod', py, - args : files('blaster.py'), + args : blaster, env : ['PYTHONPATH=' + pypathdir]) +py.install_sources(blaster) +py.install_sources(blaster, pure: true, subdir: 'pure') py3_pkg_dep = dependency('python3', method: 'pkg-config', required : false) if py3_pkg_dep.found() diff --git a/test cases/python/2 extmodule/test.json b/test cases/python/2 extmodule/test.json new file mode 100644 index 0000000..6bd1195 --- /dev/null +++ b/test cases/python/2 extmodule/test.json @@ -0,0 +1,13 @@ +{ + "installed": [ + { "type": "python_file", "file": "usr/@PYTHON_PLATLIB@/blaster.py" }, + { "type": "python_lib", "file": "usr/@PYTHON_PLATLIB@/tachyon" }, + { "type": "py_implib", "file": "usr/@PYTHON_PLATLIB@/tachyon" }, + { "type": "python_file", "file": "usr/@PYTHON_PURELIB@/pure/blaster.py" }, + { "type": "python_file", "file": "usr/@PYTHON_PLATLIB@/nested/blaster.py" }, + { "type": "python_lib", "file": "usr/@PYTHON_PLATLIB@/nested/tachyon" }, + { "type": "py_implib", "file": "usr/@PYTHON_PLATLIB@/nested/tachyon" }, + { "type": "python_lib", "file": "usr/lib/tachyon" }, + { "type": "py_implib", "file": "usr/lib/tachyon" } + ] +} -- cgit v1.1