[packages/python-ligo-segments] - rel 4, fix building with modern python
baggins
baggins at pld-linux.org
Sat Jun 7 21:35:00 CEST 2025
commit 8dea88b4c5c0b919cd66d3963d468f1ca81ba24c
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sat Jun 7 23:27:35 2025 +0200
- rel 4, fix building with modern python
PyVarObject.patch | 91 +++++++++++++++++++++++++++++++++++++++++++++++
python-ligo-segments.spec | 8 +++--
python3.13.patch | 18 ++++++++++
3 files changed, 115 insertions(+), 2 deletions(-)
---
diff --git a/python-ligo-segments.spec b/python-ligo-segments.spec
index 67ab6bb..a89a34e 100644
--- a/python-ligo-segments.spec
+++ b/python-ligo-segments.spec
@@ -3,19 +3,21 @@
%bcond_without python2 # CPython 2.x module
%bcond_without python3 # CPython 3.x module
%bcond_with py2_tests # python2 based testing (requires no longer supported lal module)
-%bcond_without py3_tests # python3 based testing
+%bcond_with py3_tests # python3 based testing (don't work due to outdated test API)
Summary: Representations of semi-open intervals
Summary(pl.UTF-8): Reprezentacja przedziałów jednostronnie otwartych
Name: python-ligo-segments
Version: 1.4.0
-Release: 3
+Release: 4
License: GPL v3+
Group: Libraries/Python
#Source0Download: https://pypi.org/simple/ligo-segments/
Source0: https://files.pythonhosted.org/packages/source/l/ligo-segments/ligo-segments-%{version}.tar.gz
# Source0-md5: ca0627db1385379ae1652f09826ea7c0
Patch0: ligo-segments-setuptools.patch
+Patch1: PyVarObject.patch
+Patch2: python3.13.patch
URL: https://pypi.org/project/ligo-segments/
%if %{with python2}
BuildRequires: python-modules >= 1:2.7
@@ -63,6 +65,8 @@ operacji na przedziałach jednostronnie otwartych.
%prep
%setup -q -n ligo-segments-%{version}
%patch -P 0 -p1
+%patch -P 1 -p1
+%patch -P 2 -p1
%build
%if %{with python2}
diff --git a/PyVarObject.patch b/PyVarObject.patch
new file mode 100644
index 0000000..daccb98
--- /dev/null
+++ b/PyVarObject.patch
@@ -0,0 +1,91 @@
+From 8705612581587f43300b83b6c382efed46147942 Mon Sep 17 00:00:00 2001
+From: Leo Singer <leo.singer at ligo.org>
+Date: Tue, 16 Jul 2024 16:00:17 -0400
+Subject: [PATCH] Initialize PyTypeObjects with PyVarObject_HEAD_INIT
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This fixes the following errors on clang (`Apple clang version 15.0.0
+(clang-1500.3.9.4)`):
+
+```
+src/infinity.c:271:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
+ PyObject_HEAD_INIT(NULL)
+ ^~~~~~~~~~~~~~~~~~~~~~~~
+/opt/local/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/object.h:142:9: note: expanded from macro 'PyObject_HEAD_INIT'
+ (type) \
+ ^~~~~~
+```
+
+and the following warnings on gcc (`gcc (Debian 12.2.0-14) 12.2.0`):
+
+```
+src/infinity.c:270:39: warning: missing braces around initializer [-Wmissing-braces]
+ 270 | PyTypeObject segments_Infinity_Type = {
+ | ^
+In file included from /usr/local/include/python3.12/Python.h:44,
+ from src/infinity.c:29:
+/usr/local/include/python3.12/object.h:142:9: warning: initialization of ‘long int’ from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
+ 142 | (type) \
+ | ^
+src/infinity.c:271:9: note: in expansion of macro ‘PyObject_HEAD_INIT’
+ 271 | PyObject_HEAD_INIT(NULL)
+ | ^~~~~~~~~~~~~~~~~~
+/usr/local/include/python3.12/object.h:142:9: note: (near initialization for ‘segments_Infinity_Type.ob_base.ob_size’)
+ 142 | (type) \
+ | ^
+src/infinity.c:271:9: note: in expansion of macro ‘PyObject_HEAD_INIT’
+ 271 | PyObject_HEAD_INIT(NULL)
+ | ^~~~~~~~~~~~~~~~~~
+```
+
+Fixes #20.
+---
+ src/infinity.c | 2 +-
+ src/segment.c | 2 +-
+ src/segmentlist.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/infinity.c b/src/infinity.c
+index d85ea13..87ceb23 100644
+--- a/src/infinity.c
++++ b/src/infinity.c
+@@ -268,7 +268,7 @@ static struct PyMethodDef methods[] = {
+
+
+ PyTypeObject segments_Infinity_Type = {
+- PyObject_HEAD_INIT(NULL)
++ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_as_number = &as_number,
+ .tp_basicsize = sizeof(segments_Infinity),
+ .tp_doc =
+diff --git a/src/segment.c b/src/segment.c
+index cc9a418..1f373c8 100644
+--- a/src/segment.c
++++ b/src/segment.c
+@@ -480,7 +480,7 @@ static struct PyMethodDef methods[] = {
+
+
+ PyTypeObject segments_Segment_Type = {
+- PyObject_HEAD_INIT(NULL)
++ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_as_number = &as_number,
+ .tp_as_sequence = &as_sequence,
+ .tp_doc =
+diff --git a/src/segmentlist.c b/src/segmentlist.c
+index 98b6b76..f666487 100644
+--- a/src/segmentlist.c
++++ b/src/segmentlist.c
+@@ -1540,7 +1540,7 @@ static struct PyMethodDef methods[] = {
+
+
+ PyTypeObject segments_SegmentList_Type = {
+- PyObject_HEAD_INIT(NULL)
++ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_as_number = &as_number,
+ .tp_as_sequence = &as_sequence,
+ .tp_doc =
+--
+GitLab
+
diff --git a/python3.13.patch b/python3.13.patch
new file mode 100644
index 0000000..c5e4460
--- /dev/null
+++ b/python3.13.patch
@@ -0,0 +1,18 @@
+--- ligo-segments-1.4.0/src/segmentlist.c.orig 2025-06-07 23:23:42.639992977 +0200
++++ ligo-segments-1.4.0/src/segmentlist.c 2025-06-07 23:23:28.316659646 +0200
+@@ -246,11 +246,15 @@
+ PyErr_SetObject(PyExc_TypeError, (PyObject *) l);
+ return -1;
+ }
++#if PY_MAJOR_VERSION < 3
+ PyObject *result = _PyList_Extend(l, v);
+ if(!result)
+ return -1;
+ Py_DECREF(result);
+ return 0;
++#else
++ return PyList_Extend((PyObject *) l, v);
++#endif
+ }
+
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python-ligo-segments.git/commitdiff/8dea88b4c5c0b919cd66d3963d468f1ca81ba24c
More information about the pld-cvs-commit
mailing list