17
0

Compare commits

4 Commits

Author SHA256 Message Date
78767edb70 Accepting request 1227765 from science
OBS-URL: https://build.opensuse.org/request/show/1227765
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-ligo-segments?expand=0&rev=6
2024-12-02 15:59:47 +00:00
9735478a41 Accepting request 1227670 from home:badshah400:branches:science
* Add python-3.13-compat.patch -- Compatibility for python 3.13, patch taken from upstream merge request
* Use %pyproject_* macros to build.
* Disable testing for now as test suite is broken (https://git.ligo.org/lscsoft/ligo-segments/-/issues/22).

OBS-URL: https://build.opensuse.org/request/show/1227670
OBS-URL: https://build.opensuse.org/package/show/science/python-ligo-segments?expand=0&rev=10
2024-12-02 12:56:01 +00:00
f7c50bf205 Accepting request 1208805 from science
OBS-URL: https://build.opensuse.org/request/show/1208805
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-ligo-segments?expand=0&rev=5
2024-10-18 13:58:05 +00:00
Ana Guerrero
71094c4040 Accepting request 1208734 from home:badshah400:branches:science
Add ligo-segments-python312-compat.patch -- Initialize PyTypeObjects with PyVarObject_HEAD_INIT for python 3.12 compatibility; upstream commit be7c93b.

OBS-URL: https://build.opensuse.org/request/show/1208734
OBS-URL: https://build.opensuse.org/package/show/science/python-ligo-segments?expand=0&rev=8
2024-10-18 07:19:09 +00:00
4 changed files with 210 additions and 5 deletions

View File

@@ -0,0 +1,92 @@
From 8705612581587f43300b83b6c382efed46147942 Mon Sep 17 00:00:00 2001
From: Leo Singer <leo.singer@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

89
python-3.13-compat.patch Normal file
View File

@@ -0,0 +1,89 @@
From b58680a5b2fa444ade61928bde1db7d261a05b32 Mon Sep 17 00:00:00 2001
From: Leo Singer <leo.singer@ligo.org>
Date: Mon, 7 Oct 2024 07:53:58 -0400
Subject: [PATCH] Fix build for Python 3.13
Use PyList_Extend for Python >= 3.13, and provide replacement
using _PyList_Extend for Python < 3.13. In Python 3.13, the
function _PyList_Extend was removed and the public API method
PyList_Extend was added in its place.
Fixes #21.
---
src/segmentlist.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
Index: ligo-segments-1.4.0/src/segmentlist.c
===================================================================
--- ligo-segments-1.4.0.orig/src/segmentlist.c
+++ ligo-segments-1.4.0/src/segmentlist.c
@@ -240,34 +240,36 @@ static PyObject *make_segment(PyObject *
}
-static int pylist_extend(PyListObject *l, PyObject *v)
+#if PY_VERSION_HEX < 0x030D0000
+static int PyList_Extend(PyObject *l, PyObject *v)
{
if(!PyList_Check(l)) {
- PyErr_SetObject(PyExc_TypeError, (PyObject *) l);
+ PyErr_SetObject(PyExc_TypeError, l);
return -1;
}
- PyObject *result = _PyList_Extend(l, v);
+ PyObject *result = _PyList_Extend((PyListObject *) l, v);
if(!result)
return -1;
Py_DECREF(result);
return 0;
}
+#endif
static PyListObject *segments_SegmentList_New(PyTypeObject *type, PyObject *sequence)
{
- PyListObject *new;
+ PyObject *new;
if(!type->tp_alloc) {
PyErr_SetObject(PyExc_TypeError, (PyObject *) type);
return NULL;
}
- new = (PyListObject *) type->tp_alloc(type, 0);
+ new = (PyObject *) type->tp_alloc(type, 0);
if(new && sequence)
- if(pylist_extend(new, sequence)) {
+ if(PyList_Extend(new, sequence) >= 0) {
Py_DECREF(new);
new = NULL;
}
- return new;
+ return (PyListObject *) new;
}
@@ -817,7 +819,7 @@ static PyObject *__ior__(PyObject *self,
/* Faster algorithm when the two lists have very different sizes.
* OK to not test size functions for error return values */
if(PySequence_Size(other) > PyList_GET_SIZE(self) / 2) {
- if(pylist_extend((PyListObject *) self, other))
+ if(PyList_Extend(self, other) >= 0)
return NULL;
return PyObject_CallMethod(self, "coalesce", NULL);
}
@@ -988,14 +990,14 @@ static PyObject *__xor__(PyObject *self,
Py_XDECREF(other);
return NULL;
}
- if(pylist_extend((PyListObject *) new, other)) {
+ if(PyList_Extend(new, other) >= 0) {
Py_DECREF(new);
Py_DECREF(other);
return NULL;
}
Py_DECREF(other);
- if(PyList_Sort(new) < 0) {
+ if(PyList_Sort(new) >= 0) {
Py_DECREF(new);
return NULL;
}

View File

@@ -1,3 +1,19 @@
-------------------------------------------------------------------
Mon Dec 2 06:30:32 UTC 2024 - Atri Bhattacharya <badshah400@gmail.com>
- Add python-3.13-compat.patch -- Compatibility for python 3.13,
patch taken from upstream merge request
- Use %pyproject_* macros to build.
- Disable testing for now as test suite is broken
(https://git.ligo.org/lscsoft/ligo-segments/-/issues/22).
-------------------------------------------------------------------
Thu Oct 17 23:12:06 UTC 2024 - Atri Bhattacharya <badshah400@gmail.com>
- Add ligo-segments-python312-compat.patch -- Initialize
PyTypeObjects with PyVarObject_HEAD_INIT for python 3.12
compatibility; upstream commit be7c93b.
-------------------------------------------------------------------
Wed Aug 24 22:57:17 UTC 2022 - Atri Bhattacharya <badshah400@gmail.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-ligo-segments
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -20,7 +20,9 @@
%ifarch %ix86
%bcond_with tests
%else
%bcond_without tests
# Disable tests for all other archs since they are broken for Python 3.13 anyway
# https://git.ligo.org/lscsoft/ligo-segments/-/issues/22
%bcond_with tests
%endif
%define skip_python2 1
@@ -32,8 +34,14 @@ License: GPL-3.0-only
Group: Development/Languages/Python
URL: https://git.ligo.org/lscsoft/ligo-segments
Source: https://files.pythonhosted.org/packages/source/l/ligo-segments/ligo-segments-%{version}.tar.gz
# PATCH-FIX-UPSTREAM ligo-segments-python312-compat.patch badshah400@gmail.com -- Initialize PyTypeObjects with PyVarObject_HEAD_INIT for python 3.12 compatibility; upstream commit
Patch0: ligo-segments-python312-compat.patch
# PATCH-FIX-UPSTREAM python-3.13-compat.patch badshah400@gmail.com -- Compatibility for python 3.13
Patch1: python-3.13-compat.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
# SECTION For tests
@@ -56,10 +64,10 @@ manipulating semi-open intervals.
%build
export CFLAGS="%{optflags}"
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%if %{with tests}
@@ -78,7 +86,7 @@ popd
%doc README.rst
%license LICENSE
%{python_sitearch}/ligo/
%{python_sitearch}/ligo_segments-%{version}-py%{python_version}.egg-info
%{python_sitearch}/ligo_segments-%{version}*.*-info
%if 0%{?suse_version} >= 1550
%{python_sitearch}/ligo_segments-%{version}-py%{python_version}-nspkg.pth
%endif