diff --git a/CHANGELOG.md b/CHANGELOG.md index b2485b5a5..5253ef92f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ - Dropped support for Python 3.9 and 3.10 as they have reached their end of life. The minimum supported Python version is now 3.11. +- The `abi3` wheels now target the stable ABI of Python 3.11 and are tagged + `cp311-abi3` instead of `cp39-abi3`. + ### Fixed - Errors raised while converting a boolean argument to a boolean (e.g. when diff --git a/setup.py b/setup.py index 9af9599f2..6cc95866b 100644 --- a/setup.py +++ b/setup.py @@ -907,19 +907,19 @@ class bdist_wheel_abi3(bdist_wheel): def get_tag(self): python, abi, plat = super().get_tag() if python.startswith("cp"): - # on CPython, our wheels are abi3 and compatible back to 3.9 - return "cp39", "abi3", plat + # on CPython, our wheels are abi3 and compatible back to 3.11 + return "cp311", "abi3", plat return python, abi, plat else: bdist_wheel_abi3 = None -# We are going to build an abi3 wheel if we are at least on CPython 3.9. +# We are going to build an abi3 wheel if we are at least on CPython 3.11. should_build_abi3_wheel = ( bdist_wheel_abi3 and platform.python_implementation() == "CPython" - and sys.version_info >= (3, 9) + and sys.version_info >= (3, 11) ) ########################################################################### @@ -939,7 +939,7 @@ def get_tag(self): sources.append(os.path.join("src", "_igraph", "force_cpp_linker.cpp")) macros = [] if should_build_abi3_wheel: - macros.append(("Py_LIMITED_API", "0x03090000")) + macros.append(("Py_LIMITED_API", "0x030B0000")) igraph_extension = Extension( "igraph._igraph", sources=sources, diff --git a/src/_igraph/bfsiter.c b/src/_igraph/bfsiter.c index c8b814f88..908755752 100644 --- a/src/_igraph/bfsiter.c +++ b/src/_igraph/bfsiter.c @@ -51,7 +51,7 @@ PyObject* igraphmodule_BFSIter_new(igraphmodule_GraphObject *g, PyObject *root, return NULL; } - Py_INCREF(g); + Py_INCREF((PyObject*)g); self->gref = g; self->graph = &g->g; @@ -121,7 +121,7 @@ static int igraphmodule_BFSIter_traverse(igraphmodule_BFSIterObject *self, visitproc visit, void *arg) { RC_TRAVERSE("BFSIter", self); Py_VISIT(self->gref); - Py_VISIT(Py_TYPE(self)); + Py_VISIT(Py_TYPE((PyObject*)self)); return 0; } @@ -156,7 +156,7 @@ static void igraphmodule_BFSIter_dealloc(igraphmodule_BFSIterObject* self) { } static PyObject* igraphmodule_BFSIter_iter(igraphmodule_BFSIterObject* self) { - Py_INCREF(self); + Py_INCREF((PyObject*)self); return (PyObject*)self; } diff --git a/src/_igraph/common.h b/src/_igraph/common.h index fda85c948..a0871e21f 100644 --- a/src/_igraph/common.h +++ b/src/_igraph/common.h @@ -23,10 +23,10 @@ #ifndef IGRAPHMODULE_COMMON_H #define IGRAPHMODULE_COMMON_H -#include - #include "preamble.h" +#include + #ifdef RC_DEBUG # define RC_ALLOC(T, P) fprintf(stderr, "[ alloc ] " T " @ %p\n", P) # define RC_DECREF(T, P) fprintf(stderr, "[ ref - ] " T " @ %p (was: %d)\n", P, (int)P->ob_refcnt); diff --git a/src/_igraph/convert.c b/src/_igraph/convert.c index 2f8f0eee6..d0848c1f2 100644 --- a/src/_igraph/convert.c +++ b/src/_igraph/convert.c @@ -22,8 +22,11 @@ /************************ Conversion functions *************************/ -#include +#include "preamble.h" + #include +#include + #include "attributes.h" #include "convert.h" #include "edgeseqobject.h" diff --git a/src/_igraph/dfsiter.c b/src/_igraph/dfsiter.c index 08a7fedea..0cc1a991a 100644 --- a/src/_igraph/dfsiter.c +++ b/src/_igraph/dfsiter.c @@ -51,7 +51,7 @@ PyObject* igraphmodule_DFSIter_new(igraphmodule_GraphObject *g, PyObject *root, return NULL; } - Py_INCREF(g); + Py_INCREF((PyObject*)g); self->gref = g; self->graph = &g->g; @@ -122,7 +122,7 @@ static int igraphmodule_DFSIter_traverse(igraphmodule_DFSIterObject *self, visitproc visit, void *arg) { RC_TRAVERSE("DFSIter", self); Py_VISIT(self->gref); - Py_VISIT(Py_TYPE(self)); + Py_VISIT(Py_TYPE((PyObject*)self)); return 0; } @@ -155,7 +155,7 @@ static void igraphmodule_DFSIter_dealloc(igraphmodule_DFSIterObject* self) { } static PyObject* igraphmodule_DFSIter_iter(igraphmodule_DFSIterObject* self) { - Py_INCREF(self); + Py_INCREF((PyObject*)self); return (PyObject*)self; } diff --git a/src/_igraph/edgeobject.c b/src/_igraph/edgeobject.c index 1d36eebcf..d1df1d421 100644 --- a/src/_igraph/edgeobject.c +++ b/src/_igraph/edgeobject.c @@ -587,7 +587,7 @@ PyObject* igraphmodule_Edge_get_vertex_tuple(igraphmodule_EdgeObject* self, void * Returns the graph where the edge belongs */ PyObject* igraphmodule_Edge_get_graph(igraphmodule_EdgeObject* self, void* closure) { - Py_INCREF(self->gref); + Py_INCREF((PyObject*)self->gref); return (PyObject*)self->gref; } @@ -598,7 +598,7 @@ PyObject* igraphmodule_Edge_get_graph(igraphmodule_EdgeObject* self, void* closu \ /* Prepend ourselves to args */ \ new_args = PyTuple_New(num_args); \ - Py_INCREF(self); \ + Py_INCREF((PyObject*)self); \ PyTuple_SetItem(new_args, 0, (PyObject*)self); \ for (i = 1; i < num_args; i++) { \ item = PyTuple_GetItem(args, i - 1); \ diff --git a/src/_igraph/edgeseqobject.c b/src/_igraph/edgeseqobject.c index fddc61d51..ec99fb40f 100644 --- a/src/_igraph/edgeseqobject.c +++ b/src/_igraph/edgeseqobject.c @@ -58,7 +58,7 @@ igraphmodule_EdgeSeqObject* igraphmodule_EdgeSeq_copy(igraphmodule_EdgeSeqObject* o) { igraphmodule_EdgeSeqObject *copy; - copy = (igraphmodule_EdgeSeqObject*) PyType_GenericNew(Py_TYPE(o), 0, 0); + copy = (igraphmodule_EdgeSeqObject*) PyType_GenericNew(Py_TYPE((PyObject*)o), 0, 0); if (copy == NULL) { return NULL; } @@ -81,7 +81,7 @@ igraphmodule_EdgeSeq_copy(igraphmodule_EdgeSeqObject* o) { copy->gref = o->gref; if (o->gref) { - Py_INCREF(o->gref); + Py_INCREF((PyObject*)o->gref); } RC_ALLOC("EdgeSeq(copy)", copy); @@ -1015,7 +1015,7 @@ PyMethodDef igraphmodule_EdgeSeq_methods[] = { */ PyObject* igraphmodule_EdgeSeq_get_graph(igraphmodule_EdgeSeqObject* self, void* closure) { - Py_INCREF(self->gref); + Py_INCREF((PyObject*)self->gref); return (PyObject*)self->gref; } diff --git a/src/_igraph/graphobject.c b/src/_igraph/graphobject.c index 01985a999..478d62508 100644 --- a/src/_igraph/graphobject.c +++ b/src/_igraph/graphobject.c @@ -47,7 +47,7 @@ PyTypeObject* igraphmodule_GraphType; #define CREATE_GRAPH(py_graph, c_graph) { \ py_graph = (igraphmodule_GraphObject*) igraphmodule_Graph_subclass_from_igraph_t( \ - Py_TYPE(self), &c_graph \ + Py_TYPE((PyObject*)self), &c_graph \ ); \ if (py_graph == NULL) { igraph_destroy(&c_graph); } \ } @@ -140,7 +140,7 @@ int igraphmodule_Graph_traverse(igraphmodule_GraphObject * self, } } - Py_VISIT(Py_TYPE(self)); + Py_VISIT(Py_TYPE((PyObject*)self)); return 0; } @@ -4600,7 +4600,7 @@ PyObject *igraphmodule_Graph_bipartite_projection(igraphmodule_GraphObject * sel if (p_g2) { CREATE_GRAPH(result2, g2); if (result2 == NULL) { - Py_XDECREF(result1); + Py_XDECREF((PyObject*)result1); return NULL; } } @@ -5172,7 +5172,7 @@ PyObject *igraphmodule_Graph_decompose(igraphmodule_GraphObject * self, /* We have to create a Python igraph object for every graph returned. During * the conversion, the graph list will be emptied as the Python list we return * from the conversion function takes ownership of all the graphs */ - list = igraphmodule_graph_list_t_to_PyList(&components, Py_TYPE(self)); + list = igraphmodule_graph_list_t_to_PyList(&components, Py_TYPE((PyObject*)self)); if (!list) { igraph_graph_list_destroy(&components); return 0; @@ -7080,7 +7080,7 @@ PyObject *igraphmodule_Graph_simplify(igraphmodule_GraphObject * self, } igraph_attribute_combination_destroy(&comb); - Py_INCREF(self); + Py_INCREF((PyObject*)self); return (PyObject *) self; } diff --git a/src/_igraph/preamble.h b/src/_igraph/preamble.h index e70f91c0a..fae0554e9 100644 --- a/src/_igraph/preamble.h +++ b/src/_igraph/preamble.h @@ -25,11 +25,21 @@ #ifndef PY_IGRAPH_ALLOW_ENTIRE_PYTHON_API # ifndef Py_LIMITED_API -# define Py_LIMITED_API 0x03090000 +# define Py_LIMITED_API 0x030B0000 # endif #endif #define PY_SSIZE_T_CLEAN #include +/* Python.h stops including these standard headers when Py_LIMITED_API is + * 3.11 (: 3.13) or later, but the extension relies on them. + * Python.h must be included before any standard header, so include them + * here instead of at the top of individual source files. */ +#include +#include +#include +#include +#include + #endif /* PYTHON_IGRAPH_PREAMBLE_H */ diff --git a/src/_igraph/pyhelpers.h b/src/_igraph/pyhelpers.h index 2dba07a44..030581c37 100644 --- a/src/_igraph/pyhelpers.h +++ b/src/_igraph/pyhelpers.h @@ -52,7 +52,7 @@ char* igraphmodule_PyUnicode_CopyAsString(PyObject* string); /* Calling Py_DECREF() on heap-allocated types in tp_dealloc was not needed * before Python 3.8 (see Python issue 35810) */ #define PY_FREE_AND_DECREF_TYPE(obj, base_type) { \ - PyTypeObject* _tp = Py_TYPE(obj); \ + PyTypeObject* _tp = Py_TYPE((PyObject*)(obj)); \ ((freefunc)PyType_GetSlot(_tp, Py_tp_free))(obj); \ Py_DECREF(_tp); \ } diff --git a/src/_igraph/vertexobject.c b/src/_igraph/vertexobject.c index 45490c63b..bc9073a50 100644 --- a/src/_igraph/vertexobject.c +++ b/src/_igraph/vertexobject.c @@ -581,7 +581,7 @@ igraph_int_t igraphmodule_Vertex_get_index_igraph_integer(igraphmodule_VertexObj */ PyObject* igraphmodule_Vertex_get_graph(igraphmodule_VertexObject* self, void* closure) { - Py_INCREF(self->gref); + Py_INCREF((PyObject*)self->gref); return (PyObject*)self->gref; } @@ -695,7 +695,7 @@ static PyObject* _convert_to_vertex_list(igraphmodule_VertexObject* vertex, PyOb \ /* Prepend ourselves to args */ \ new_args = PyTuple_New(num_args); \ - Py_INCREF(self); \ + Py_INCREF((PyObject*)self); \ PyTuple_SetItem(new_args, 0, (PyObject*)self); \ for (i = 1; i < num_args; i++) { \ item = PyTuple_GetItem(args, i - 1); \ diff --git a/src/_igraph/vertexseqobject.c b/src/_igraph/vertexseqobject.c index cb9ca3470..81b76098c 100644 --- a/src/_igraph/vertexseqobject.c +++ b/src/_igraph/vertexseqobject.c @@ -58,7 +58,7 @@ igraphmodule_VertexSeqObject* igraphmodule_VertexSeq_copy(igraphmodule_VertexSeqObject* o) { igraphmodule_VertexSeqObject *copy; - copy = (igraphmodule_VertexSeqObject*) PyType_GenericNew(Py_TYPE(o), 0, 0); + copy = (igraphmodule_VertexSeqObject*) PyType_GenericNew(Py_TYPE((PyObject*)o), 0, 0); if (copy == NULL) { return NULL; } @@ -80,7 +80,7 @@ igraphmodule_VertexSeq_copy(igraphmodule_VertexSeqObject* o) { } copy->gref = o->gref; - if (o->gref) Py_INCREF(o->gref); + if (o->gref) Py_INCREF((PyObject*)o->gref); RC_ALLOC("VertexSeq(copy)", copy); return copy; @@ -981,7 +981,7 @@ int igraphmodule_VertexSeq_to_vector_t(igraphmodule_VertexSeqObject *self, */ PyObject* igraphmodule_VertexSeq_get_graph(igraphmodule_VertexSeqObject* self, void* closure) { - Py_INCREF(self->gref); + Py_INCREF((PyObject*)self->gref); return (PyObject*)self->gref; }