diff --git a/test/09_setup_cfg/cibuildwheel_test.py b/test/09_setup_cfg/cibuildwheel_test.py new file mode 100644 index 00000000..9e9ffce6 --- /dev/null +++ b/test/09_setup_cfg/cibuildwheel_test.py @@ -0,0 +1,13 @@ +import os +import utils + + +project_dir = os.path.dirname(__file__) + +def test(): + # build the wheels + actual_wheels = utils.cibuildwheel_run(project_dir) + + # check that the expected wheels are produced + expected_wheels = utils.expected_wheels('spam', '0.1.0') + assert set(actual_wheels) == set(expected_wheels) diff --git a/test/09_setup_cfg/setup.cfg b/test/09_setup_cfg/setup.cfg new file mode 100644 index 00000000..b42c221a --- /dev/null +++ b/test/09_setup_cfg/setup.cfg @@ -0,0 +1,6 @@ +[metadata] +name = spam +version = attr: spam.__version__ + +[options] +packages = find: \ No newline at end of file diff --git a/test/09_setup_cfg/setup.py b/test/09_setup_cfg/setup.py new file mode 100644 index 00000000..0fbbe75e --- /dev/null +++ b/test/09_setup_cfg/setup.py @@ -0,0 +1,8 @@ +import os + +from setuptools import setup, Extension + + +setup( + ext_modules=[Extension('spam.spam', sources=['spam/spam.c'])], +) diff --git a/test/09_setup_cfg/spam/__init__.py b/test/09_setup_cfg/spam/__init__.py new file mode 100644 index 00000000..a68927d6 --- /dev/null +++ b/test/09_setup_cfg/spam/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0" \ No newline at end of file diff --git a/test/09_setup_cfg/spam/spam.c b/test/09_setup_cfg/spam/spam.c new file mode 100644 index 00000000..d1ab0f22 --- /dev/null +++ b/test/09_setup_cfg/spam/spam.c @@ -0,0 +1,48 @@ +#include + +static PyObject * +spam_system(PyObject *self, PyObject *args) +{ + const char *command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + return PyLong_FromLong(sts); +} + +/* Module initialization */ + +#if PY_MAJOR_VERSION >= 3 + #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, name, doc, module_state_size, methods, }; \ + m = PyModule_Create(&moduledef); + #define MOD_RETURN(m) return m; +#else + #define MOD_INIT(name) PyMODINIT_FUNC init##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + m = Py_InitModule3(name, methods, doc); + #define MOD_RETURN(m) return; +#endif + +static PyMethodDef module_methods[] = { + {"system", (PyCFunction)spam_system, METH_VARARGS, + "Execute a shell command."}, + {NULL} /* Sentinel */ +}; + +MOD_INIT(spam) +{ + PyObject* m; + + MOD_DEF(m, + "spam", + "Example module", + module_methods, + -1) + + MOD_RETURN(m) +}