Skip to contentSkip to conversation

python3-lru-dict: Fix function pointer mismatch

PATCH New Khem Raj 1 participant 3 messages Mar 2, 2023

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 python3-lru-dict: Fix function pointer mismatch

---
 ...ion-instead-of-PyCFunctionWithKeywor.patch | 37 +++++++++++++++++++
 .../python/python3-lru-dict_1.1.8.bb          |  2 +
 2 files changed, 39 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-lru-dict/0001-lru-Use-PyCFunction-instead-of-PyCFunctionWithKeywor.patch
meta-python/recipes-devtools/python/python3-lru-dict/0001-lru-Use-PyCFunction-instead-of-PyCFunctionWithKeywor.patch new file +37 -0
new file mode 100644
index 0000000000..b93d1594da
@@ -0,0 +1,37 @@
+From 5013406c409a0a143a315146df388281bfb2172d Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 1 Mar 2023 19:53:36 -0800
+Subject: [PATCH] lru: Use PyCFunction instead of PyCFunctionWithKeywords
+
+PyMethodDef uses PyMethodDef and not PyCFunctionWithKeywords and when
+callback is specified as PyCFunctionWithKeywords, clang 16+ is able to
+detect function signature mismatch in function pointers now.
+
+Fixes
+lru.c:629:17: error: incompatible function pointer types initializing 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') with an expression of type 'PyCFunctionWithKeywords' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') [-Wincompatible-function-pointer-types]
+    {"popitem", (PyCFunctionWithKeywords)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
+                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+1 error generated.
+
+Upstream-Status: Submitted [https://github.com/amitdev/lru-dict/pull/45]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ lru.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lru.c b/lru.c
+index 8adcb4b..33c18ab 100644
+--- a/lru.c
++++ b/lru.c
+@@ -626,7 +626,7 @@ static PyMethodDef LRU_methods[] = {
+                     PyDoc_STR("L.setdefault(key, default=None) -> If L has key return its value, otherwise insert key with a value of default and return default")},
+     {"pop", (PyCFunction)LRU_pop, METH_VARARGS,
+                     PyDoc_STR("L.pop(key[, default]) -> If L has key return its value and remove it from L, otherwise return default. If default is not given and key is not in L, a KeyError is raised.")},
+-    {"popitem", (PyCFunctionWithKeywords)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
++    {"popitem", (PyCFunction)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
+                     PyDoc_STR("L.popitem([least_recent=True]) -> Returns and removes a (key, value) pair. The pair returned is the least-recently used if least_recent is true, or the most-recently used if false.")},
+     {"set_size", (PyCFunction)LRU_set_size, METH_VARARGS,
+                     PyDoc_STR("L.set_size() -> set size of LRU")},
+-- 
+2.39.2
+
meta-python/recipes-devtools/python/python3-lru-dict_1.1.8.bb +2 -0
index b870bc0889..e825e43dfe 100644
@@ -7,3 +7,5 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=9d10a486ee04034fdef5162fd791f153"
 SRC_URI[sha256sum] = "878bc8ef4073e5cfb953dfc1cf4585db41e8b814c0106abde34d00ee0d0b3115"
 
 inherit pypi setuptools3
+
+SRC_URI += "file://0001-lru-Use-PyCFunction-instead-of-PyCFunctionWithKeywor.patch"
Signature · 1 line
2.39.2
author
#1 lore raw

PATCH 2/3 hdf5: Upgrade to 1.14.0

---
 .../hdf5/files/0001-cmake-remove-build-flags.patch          | 6 +++---
 ...0002-Remove-suffix-shared-from-shared-library-name.patch | 2 +-
 .../recipes-support/hdf5/{hdf5_1.13.2.bb => hdf5_1.14.0.bb} | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename meta-oe/recipes-support/hdf5/{hdf5_1.13.2.bb => hdf5_1.14.0.bb} (91%)
meta-oe/recipes-support/hdf5/files/0001-cmake-remove-build-flags.patch +3 -3
index 642d7d1662..a8050cc55b 100644
@@ -15,7 +15,7 @@ Signed-off-by: Mingli Yu <[email protected]>
 
 --- a/config/cmake/libh5cc.in
 +++ b/config/cmake/libh5cc.in
-@@ -45,7 +45,7 @@ for arg in $@ ; do
+@@ -44,7 +44,7 @@ for arg in $@ ; do
        exit $status
        ;;
      *)
@@ -45,8 +45,8 @@ Signed-off-by: Mingli Yu <[email protected]>
                      H5_CPPFLAGS: @H5_CPPFLAGS@
                      AM_CPPFLAGS: @AM_CPPFLAGS@
                           CFLAGS: @CMAKE_C_FLAGS@
-@@ -52,8 +52,8 @@ Languages:
- @BUILD_FORTRAN_CONDITIONAL_TRUE@         Static Fortran Library: @H5_ENABLE_STATIC_LIB@
+@@ -53,8 +53,8 @@ Languages:
+ @BUILD_FORTRAN_CONDITIONAL_TRUE@               Module Directory: @CMAKE_Fortran_MODULE_DIRECTORY@
  
                              C++: @HDF5_BUILD_CPP_LIB@
 -@BUILD_CXX_CONDITIONAL_TRUE@                   C++ Compiler: @CMAKE_CXX_COMPILER@ @CMAKE_CXX_COMPILER_VERSION@
meta-oe/recipes-support/hdf5/files/0002-Remove-suffix-shared-from-shared-library-name.patch +1 -1
index de052451bd..f0eb05a1e7 100644
@@ -12,7 +12,7 @@ Signed-off-by: Hongxu Jia <[email protected]>
 
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -196,19 +196,19 @@ set (HDF5_HL_F90_C_LIB_TARGET     "${HDF
+@@ -191,19 +191,19 @@ set (HDF5_HL_F90_C_LIB_TARGET     "${HDF
  set (HDF5_JAVA_JNI_LIB_TARGET     "${HDF5_JAVA_JNI_LIB_CORENAME}")
  set (HDF5_JAVA_HDF5_LIB_TARGET    "${HDF5_JAVA_HDF5_LIB_CORENAME}")
  set (HDF5_JAVA_TEST_LIB_TARGET    "${HDF5_JAVA_TEST_LIB_CORENAME}")
meta-oe/recipes-support/hdf5/hdf5_1.14.0.bb renamed from meta-oe/recipes-support/hdf5/hdf5_1.13.2.bb +2 -2
similarity index 91%
rename from meta-oe/recipes-support/hdf5/hdf5_1.13.2.bb
rename to meta-oe/recipes-support/hdf5/hdf5_1.14.0.bb
index 80611c6714..4feec61afd 100644
@@ -12,11 +12,11 @@ inherit cmake siteinfo qemu
 DEPENDS += "qemu-native"
 
 SRC_URI = " \
-    https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.13/hdf5-${PV}/src/${BPN}-${PV}.tar.bz2 \
+    https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-${PV}/src/${BPN}-${PV}.tar.bz2 \
     file://0002-Remove-suffix-shared-from-shared-library-name.patch \
     file://0001-cmake-remove-build-flags.patch \
 "
-SRC_URI[sha256sum] = "9c51b3da426977ec622a43dca8adaf4e81eabf838c1ff80c6225ad1d3ed54b5c"
+SRC_URI[sha256sum] = "e4e79433450edae2865a4c6328188bb45391b29d74f8c538ee699f0b116c2ba0"
 
 FILES:${PN} += "${libdir}/libhdf5.settings ${datadir}/*"
 
Signature · 1 line
2.39.2
author
#2 lore raw

PATCH 3/3 python3-h5py: Upgrade to 3.8.0

In reply to Khem Raj

Drop unused patches

---
 .../0001-fix-wrong-file-driver-version.patch  | 53 -------------------
 .../0001-setup.py-Fix-numpy-version.patch     | 28 ----------
 ...n3-h5py_3.7.0.bb => python3-h5py_3.8.0.bb} |  9 ++--
 3 files changed, 3 insertions(+), 87 deletions(-)
 delete mode 100644 meta-python/recipes-devtools/python/python3-h5py/0001-fix-wrong-file-driver-version.patch
 delete mode 100644 meta-python/recipes-devtools/python/python3-h5py/0001-setup.py-Fix-numpy-version.patch
 rename meta-python/recipes-devtools/python/{python3-h5py_3.7.0.bb => python3-h5py_3.8.0.bb} (70%)
meta-python/recipes-devtools/python/python3-h5py/0001-fix-wrong-file-driver-version.patch deleted +0 -53
deleted file mode 100644
index 2692acde75..0000000000
@@ -1,53 +0,0 @@
-From 5b0b1d0b941ba338d449f9261bdf4cb2b679d048 Mon Sep 17 00:00:00 2001
-From: Hongxu Jia <[email protected]>
-Date: Tue, 20 Sep 2022 02:53:11 -0700
-Subject: [PATCH] fix wrong file driver version
-
-Due to commit [1] applied in hdf5 (1.13.2), import hdf5 failed
-
-|>>> import h5py
-|Traceback (most recent call last):
-|  File "<stdin>", line 1, in <module>
-|  File "/usr/lib/python3.10/site-packages/h5py/__init__.py", line 56, in <module>
-|    from . import h5a, h5d, h5ds, h5f, h5fd, h5g, h5r, h5s, h5t, h5p, h5z, h5pl
-|  File "h5py/h5fd.pyx", line 220, in init h5py.h5fd
-|RuntimeError: Wrong file driver version # (wrong file driver version #)
-
-Initial driver version to fix the error
-
-[1] https://github.com/HDFGroup/hdf5/commit/42b767fc67ad1e13735e3cee2077f2e108f9463e
-
-Upstream-Status: Submitted  [https://github.com/h5py/h5py/pull/2153]
-Signed-off-by: Hongxu Jia <[email protected]>
----
- h5py/api_types_hdf5.pxd | 1 +
- h5py/h5fd.pyx           | 1 +
- 2 files changed, 2 insertions(+)
-
-diff --git a/h5py/api_types_hdf5.pxd b/h5py/api_types_hdf5.pxd
-index 6977f1a7..312fdaa0 100644
---- a/h5py/api_types_hdf5.pxd
-+++ b/h5py/api_types_hdf5.pxd
-@@ -237,6 +237,7 @@ cdef extern from "hdf5.h":
- 
-   # Class information for each file driver
-   ctypedef struct H5FD_class_t:
-+    unsigned version;
-     const char *name
-     haddr_t maxaddr
-     H5F_close_degree_t fc_degree
-diff --git a/h5py/h5fd.pyx b/h5py/h5fd.pyx
-index 04aff077..d41953d0 100644
---- a/h5py/h5fd.pyx
-+++ b/h5py/h5fd.pyx
-@@ -191,6 +191,7 @@ cdef herr_t H5FD_fileobj_flush(H5FD_fileobj_t *f, hid_t dxpl, hbool_t closing) e
- cdef H5FD_class_t info
- memset(&info, 0, sizeof(info))
- 
-+info.version = 0x01
- info.name = 'fileobj'
- info.maxaddr = libc.stdint.SIZE_MAX - 1
- info.fc_degree = H5F_CLOSE_WEAK
--- 
-2.37.1
-
meta-python/recipes-devtools/python/python3-h5py/0001-setup.py-Fix-numpy-version.patch deleted +0 -28
deleted file mode 100644
index 9b79cc5395..0000000000
@@ -1,28 +0,0 @@
-From b1d4d171fd13624f3d8bb917f716b62494066501 Mon Sep 17 00:00:00 2001
-From: Leon Anavi <[email protected]>
-Date: Mon, 22 Feb 2021 18:42:43 +0200
-Subject: [PATCH] setup.py: Fix numpy version
-
-Fix numpy version to ensure bitbake will find the pip package.
-
-Upstream-Status: Inappropriate [oe specific]
-
-Signed-off-by: Leon Anavi <[email protected]>
-
----
- setup.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/setup.py b/setup.py
-index 4b2890c..42ba21b 100755
---- a/setup.py
-+++ b/setup.py
-@@ -49,7 +49,7 @@ SETUP_REQUIRES = [
-     "Cython >=0.29.14; python_version=='3.8'",
-     "Cython >=0.29.15; python_version>='3.9'",
- ] + [
--    f"numpy =={np_min}; python_version{py_condition}"
-+    f"numpy >={np_min}; python_version{py_condition}"
-     for np_min, py_condition in NUMPY_MIN_VERSIONS
- ]
- 
meta-python/recipes-devtools/python/python3-h5py_3.8.0.bb renamed from meta-python/recipes-devtools/python/python3-h5py_3.7.0.bb +3 -6
similarity index 70%
rename from meta-python/recipes-devtools/python/python3-h5py_3.7.0.bb
rename to meta-python/recipes-devtools/python/python3-h5py_3.8.0.bb
index ce4f05dbed..75a41e29dc 100644
@@ -4,12 +4,9 @@ SECTION = "devel/python"
 LICENSE = "BSD-3-Clause"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=113251d71fb0384712c719b567261c5c"
 
-SRC_URI[sha256sum] = "3fcf37884383c5da64846ab510190720027dca0768def34dd8dcb659dbe5cbf3"
+SRC_URI[sha256sum] = "6fead82f0c4000cf38d53f9c030780d81bfa0220218aee13b90b7701c937d95f"
 
-SRC_URI:append = " \
-           file://0001-setup_build.py-avoid-absolute-path.patch \
-           file://0001-fix-wrong-file-driver-version.patch \
-          "
+SRC_URI += "file://0001-setup_build.py-avoid-absolute-path.patch"
 
 inherit pkgconfig pypi setuptools3
 
@@ -29,4 +26,4 @@ RDEPENDS:${PN} = "python3-numpy \
                   python3-json \
                  "
 
-export HDF5_VERSION="1.13.2"
+export HDF5_VERSION="1.14.0"
Signature · 1 line
2.39.2