summaryrefslogtreecommitdiff
path: root/test cases/python/2 extmodule/ext
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/python/2 extmodule/ext')
-rw-r--r--test cases/python/2 extmodule/ext/meson.build6
-rw-r--r--test cases/python/2 extmodule/ext/nested/meson.build17
-rw-r--r--test cases/python/2 extmodule/ext/tachyon_module.c14
-rw-r--r--test cases/python/2 extmodule/ext/wrongdir/meson.build6
4 files changed, 41 insertions, 2 deletions
diff --git a/test cases/python/2 extmodule/ext/meson.build b/test cases/python/2 extmodule/ext/meson.build
index 14fa94abf..0fba9f582 100644
--- a/test cases/python/2 extmodule/ext/meson.build
+++ b/test cases/python/2 extmodule/ext/meson.build
@@ -4,6 +4,12 @@ pylib = py.extension_module('tachyon',
install: true,
)
+pylib2 = py2.extension_module('tachyon',
+ 'tachyon_module.c',
+ 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
index 34c119273..4a7ec7675 100644
--- a/test cases/python/2 extmodule/ext/nested/meson.build
+++ b/test cases/python/2 extmodule/ext/nested/meson.build
@@ -13,3 +13,20 @@ py.install_sources(
pure: false,
subdir: 'nested',
)
+
+
+py2.extension_module('tachyon',
+ '../tachyon_module.c',
+ c_args: '-DMESON_MODULENAME="nested.tachyon"',
+ install: true,
+ subdir: 'nested'
+)
+py2.install_sources(
+ configure_file(
+ input: '../../blaster.py.in',
+ output: 'blaster.py',
+ configuration: {'tachyon_module': 'nested.tachyon'}
+ ),
+ pure: false,
+ 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 a5d7cdc98..68eda5380 100644
--- a/test cases/python/2 extmodule/ext/tachyon_module.c
+++ b/test cases/python/2 extmodule/ext/tachyon_module.c
@@ -1,5 +1,5 @@
/*
- Copyright 2016 The Meson development team
+ Copyright 2018 The Meson development team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,7 +27,11 @@ static PyObject* phaserize(PyObject *self, PyObject *args) {
return NULL;
result = strcmp(message, "shoot") ? 0 : 1;
+#if PY_VERSION_HEX < 0x03000000
+ return PyInt_FromLong(result);
+#else
return PyLong_FromLong(result);
+#endif
}
static PyMethodDef TachyonMethods[] = {
@@ -36,9 +40,14 @@ static PyMethodDef TachyonMethods[] = {
{NULL, NULL, 0, NULL}
};
+#if PY_VERSION_HEX < 0x03000000
+PyMODINIT_FUNC inittachyon(void) {
+ Py_InitModule("tachyon", TachyonMethods);
+}
+#else
static struct PyModuleDef tachyonmodule = {
PyModuleDef_HEAD_INIT,
- MESON_MODULENAME,
+ "tachyon",
NULL,
-1,
TachyonMethods
@@ -47,3 +56,4 @@ static struct PyModuleDef tachyonmodule = {
PyMODINIT_FUNC PyInit_tachyon(void) {
return PyModule_Create(&tachyonmodule);
}
+#endif
diff --git a/test cases/python/2 extmodule/ext/wrongdir/meson.build b/test cases/python/2 extmodule/ext/wrongdir/meson.build
index 5074701ea..79b13eb77 100644
--- a/test cases/python/2 extmodule/ext/wrongdir/meson.build
+++ b/test cases/python/2 extmodule/ext/wrongdir/meson.build
@@ -4,3 +4,9 @@ py.extension_module('tachyon',
install: true,
install_dir: get_option('libdir')
)
+py2.extension_module('tachyon',
+ '../tachyon_module.c',
+ c_args: '-DMESON_MODULENAME="tachyon"',
+ install: true,
+ install_dir: get_option('libdir')
+)