Commit 728fae79 authored by Kipp Cannon's avatar Kipp Cannon

remove six.h from build

parent 6a8abe27
Pipeline #44059 failed with stages
in 1 minute and 37 seconds
......@@ -28,7 +28,6 @@
#include <Python.h>
#include <segments.h>
#include "six.h"
/*
......@@ -43,37 +42,51 @@
#define MODULE_DOC "C implementations of the infinity, segment, and segmentlist classes from the segments module."
static PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
MODULE_NAME, MODULE_DOC, -1, NULL
};
#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init__segments(void); /* Silence -Wmissing-prototypes */
PyMODINIT_FUNC init__segments(void)
#else
PyMODINIT_FUNC PyInit___segments(void); /* Silence -Wmissing-prototypes */
PyMODINIT_FUNC PyInit___segments(void)
#endif
{
PyObject *module = NULL;
#if PY_MAJOR_VERSION < 3
PyObject *module = Py_InitModule3(MODULE_NAME, NULL, MODULE_DOC);
#else
static struct PyModuleDef modef = {
PyModuleDef_HEAD_INIT,
.m_name = MODULE_NAME,
.m_doc = MODULE_DOC,
.m_size = -1,
.m_methods = NULL,
};
PyObject *module = PyModule_Create(&modef);
#endif
if(!module)
goto done;
if(PyType_Ready(&segments_Infinity_Type) < 0)
if(PyType_Ready(&segments_Infinity_Type) < 0) {
Py_DECREF(module);
module = NULL;
goto done;
}
segments_Segment_Type.tp_base = &PyTuple_Type;
if(!segments_Segment_Type.tp_hash)
segments_Segment_Type.tp_hash = PyTuple_Type.tp_hash;
if(PyType_Ready(&segments_Segment_Type) < 0)
if(PyType_Ready(&segments_Segment_Type) < 0) {
Py_DECREF(module);
module = NULL;
goto done;
}
segments_SegmentList_Type.tp_base = &PyList_Type;
if(PyType_Ready(&segments_SegmentList_Type) < 0)
goto done;
/*
* Initialize module
*/
module = PyModule_Create(&moduledef);
if (!module)
if(PyType_Ready(&segments_SegmentList_Type) < 0) {
Py_DECREF(module);
module = NULL;
goto done;
}
/*
* Create infinity class
......@@ -113,8 +126,9 @@ PyMODINIT_FUNC PyInit___segments(void)
PyModule_AddObject(module, "segmentlist", (PyObject *) &segments_SegmentList_Type);
done:
#if PY_MAJOR_VERSION < 3
return;
#else
return module;
#endif
}
SIX_COMPAT_MODULE(__segments)
/*
* Copyright (C) 2016 Leo Singer
*
* Fake implementations of some parts of the Python C API functions to aid
* 2 to 3 porting. Named after the 'six' package that serves a similar
* purpose for pure Python code (https://pypi.python.org/pypi/six).
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Python.h>
#ifndef _SIX_H
#define _SIX_H
#if PY_MAJOR_VERSION < 3
#ifdef PyMODINIT_FUNC
#undef PyMODINIT_FUNC
#define PyMODINIT_FUNC PyObject*
#endif
#define SIX_COMPAT_MODULE(name) _SIX_COMPAT_MODULE(name)
#define _SIX_COMPAT_MODULE(name) \
void init##name(void); /* Silence -Wmissing-prototypes */ \
void init##name(void) { \
PyInit_##name(); \
}
typedef struct PyModuleDef {
int m_base;
const char *m_name;
const char *m_doc;
Py_ssize_t m_size;
PyMethodDef *m_methods;
} PyModuleDef;
#define PyModuleDef_HEAD_INIT 0
static PyObject *PyModule_Create(PyModuleDef *def)
{
(void)PyModule_Create; /* Suppress unused function warning */
if (def->m_size != -1)
{
PyErr_SetString(PyExc_NotImplementedError,
"Python 2 does not support per-module state.");
return NULL;
}
return Py_InitModule3(def->m_name, def->m_methods, def->m_doc);
}
static PyObject *PyModule_Create2(PyModuleDef *def, int module_api_version)
{
(void)PyModule_Create2; /* Suppress unused function warning */
if (def->m_size != -1)
{
PyErr_SetString(PyExc_NotImplementedError,
"Python 2 does not support per-module state.");
return NULL;
}
return Py_InitModule4(def->m_name, def->m_methods, def->m_doc,
NULL, module_api_version);
}
#ifdef NUMPY_IMPORT_ARRAY_RETVAL
#undef NUMPY_IMPORT_ARRAY_RETVAL
#endif
#define NUMPY_IMPORT_ARRAY_RETVAL NULL
#ifdef NUMPY_IMPORT_UMATH_RETVAL
#undef NUMPY_IMPORT_UMATH_RETVAL
#endif
#define NUMPY_IMPORT_UMATH_RETVAL NULL
#else /* PY_MAJOR_VERSION >= 3 */
#define SIX_COMPAT_MODULE(name)
#endif
#endif /* _SIX_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment