summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-03-18 22:07:42 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-03-20 08:32:32 -0400
commit20fa738123d005bb543a09974c5c981917d10264 (patch)
treed80908f112c94b80c26cd54aef3681900743cdd6 /gnu
parent9956638943df3b9902055dd80df98035c014c56c (diff)
gnu: python-hiredis: Update to 2.2.2 and enable tests.
* gnu/packages/databases.scm (python-hiredis): Update to 2.2.2. [source]: Fetch via git and apply patches. [build-system]: Use pyproject-build-system. [arguments]: Enable tests. Add #:phases. [native-inputs]: New field. [inputs]: Likewise. * gnu/packages/patches/python-hiredis-fix-header.patch: New file. * gnu/packages/patches/python-hiredis-use-system-hiredis.patch: Likewise. * gnu/local.mk (dist_patch_DATA): Register them.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk2
-rw-r--r--gnu/packages/databases.scm33
-rw-r--r--gnu/packages/patches/python-hiredis-fix-header.patch49
-rw-r--r--gnu/packages/patches/python-hiredis-use-system-hiredis.patch82
4 files changed, 155 insertions, 11 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 1b922a9356..2abece0d2f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1738,6 +1738,8 @@ dist_patch_DATA = \
%D%/packages/patches/python-docopt-pytest6-compat.patch \
%D%/packages/patches/python-execnet-read-only-fix.patch \
%D%/packages/patches/python-fixtures-remove-monkeypatch-test.patch \
+ %D%/packages/patches/python-hiredis-fix-header.patch \
+ %D%/packages/patches/python-hiredis-use-system-hiredis.patch \
%D%/packages/patches/python-ipython-documentation-chars.patch \
%D%/packages/patches/python-ipython-documentation-repro.patch \
%D%/packages/patches/python-keras-integration-test.patch \
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 0de144e6b8..3a21f64819 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -3904,18 +3904,29 @@ for Python. The design goals are:
(define-public python-hiredis
(package
(name "python-hiredis")
- (version "0.2.0")
- (source
- (origin
- (method url-fetch)
- (uri (pypi-uri "hiredis" version))
- (sha256
- (base32
- "1dfm2k9l9zar9nw9fwmm74zrgraxdxs04vx9li56fjcf289qx5fa"))))
- (build-system python-build-system)
+ (version "2.2.2")
+ (source (origin
+ (method git-fetch) ;for tests
+ (uri (git-reference
+ (url "https://github.com/redis/hiredis-py")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "066rm5m7aa8skm0a57cf45153bwmbl9yyi4s60an14hb25n947gi"))
+ (patches
+ (search-patches "python-hiredis-fix-header.patch"
+ "python-hiredis-use-system-hiredis.patch"))))
+ (build-system pyproject-build-system)
(arguments
- ;; no tests
- `(#:tests? #f))
+ (list #:phases #~(modify-phases %standard-phases
+ (add-before 'check 'delete-extraneous-__init__.py
+ (lambda _
+ ;; The fix was forwarded upstream, see:
+ ;; https://github.com/redis/hiredis-py/pull/160.
+ (delete-file "tests/__init__.py"))))))
+ (native-inputs (list python-pytest))
+ (inputs (list hiredis))
(home-page "https://github.com/redis/hiredis-py")
(synopsis "Python extension that wraps protocol parsing code in hiredis")
(description "Python-hiredis is a python extension that wraps protocol
diff --git a/gnu/packages/patches/python-hiredis-fix-header.patch b/gnu/packages/patches/python-hiredis-fix-header.patch
new file mode 100644
index 0000000000..168b76920d
--- /dev/null
+++ b/gnu/packages/patches/python-hiredis-fix-header.patch
@@ -0,0 +1,49 @@
+Upstream status: https://github.com/redis/hiredis-py/pull/159
+
+From c2a20695aae53de7b5160e29675344df0b805fa6 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Sat, 18 Mar 2023 15:18:08 -0400
+Subject: [PATCH] pack: Replace sdsalloc.h with alloc.h
+
+Fixes #158.
+
+* src/pack.c: Replace sdsalloc.h with alloc.h.
+(pack_command): Replace s_malloc with hi_malloc.
+---
+ src/pack.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/pack.c b/src/pack.c
+index 443e9d3..23e4004 100644
+--- a/src/pack.c
++++ b/src/pack.c
+@@ -16,7 +16,7 @@ extern sds sdscpylen(sds s, const char *t, size_t len);
+ extern sds sdsnewlen(const void *init, size_t initlen);
+ #endif
+
+-#include <hiredis/sdsalloc.h>
++#include <hiredis/alloc.h>
+
+ PyObject *
+ pack_command(PyObject *cmd)
+@@ -32,7 +32,7 @@ pack_command(PyObject *cmd)
+ }
+
+ Py_ssize_t tokens_number = PyTuple_Size(cmd);
+- sds *tokens = s_malloc(sizeof(sds) * tokens_number);
++ sds *tokens = hi_malloc(sizeof(sds) * tokens_number);
+ if (tokens == NULL)
+ {
+ return PyErr_NoMemory();
+@@ -118,4 +118,4 @@ cleanup:
+ sdsfreesplitres(tokens, tokens_number);
+ hi_free(lengths);
+ return result;
+-}
+\ No newline at end of file
++}
+
+base-commit: 8adb1b3cb38b82cdc73fa2d72879712da1f74e70
+--
+2.39.1
+
diff --git a/gnu/packages/patches/python-hiredis-use-system-hiredis.patch b/gnu/packages/patches/python-hiredis-use-system-hiredis.patch
new file mode 100644
index 0000000000..622f049da7
--- /dev/null
+++ b/gnu/packages/patches/python-hiredis-use-system-hiredis.patch
@@ -0,0 +1,82 @@
+Upstream status: https://github.com/redis/hiredis-py/pull/161
+
+From 7b3c8a364f6167f4b1828dd9c48ada3d8b0786f6 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Sat, 18 Mar 2023 21:32:21 -0400
+Subject: [PATCH] setup.py: Fallback to use the system hiredis library.
+
+Fixes #158 fully, including using a system-prodived hiredis.
+
+When the hiredis git submodule hasn't been initialized, print a
+message about it, and attempt to link against the a system-provided
+hiredis library instead.
+
+* setup.py (is_hiredis_bundled): New procedure.
+(get_hiredis_bundled_sources): Likewise. Print a message when
+bundled_hiredis_sources is empty.
+(get_sources): Adjust to use the above procedure.
+(get_linker_args): Add -lhiredis when the bundled hiredis is not used.
+---
+ setup.py | 30 +++++++++++++++++++++++++++---
+ 1 file changed, 27 insertions(+), 3 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 905df59..a77aca3 100644
+--- a/setup.py
++++ b/setup.py
+@@ -7,6 +7,7 @@ except ImportError:
+ import importlib
+ import glob
+ import io
++import os
+ import sys
+
+
+@@ -17,16 +18,39 @@ def version():
+ return module.__version__
+
+
++def is_hiredis_bundled():
++ hiredis_submodule = 'vendor/hiredis'
++ if (os.path.exists(hiredis_submodule)
++ and not os.path.isfile(hiredis_submodule)):
++ return not os.listdir()
++ return False
++
++
++def get_hiredis_bundled_sources():
++ hiredis_sources = ("alloc", "async", "hiredis", "net", "read",
++ "sds", "sockcompat")
++ if is_hiredis_bundled():
++ return ["vendor/hiredis/%s.c" % src for src in hiredis_sources]
++ return []
++
++
++if not is_hiredis_bundled():
++ print('the bundled hiredis sources were not found;'
++ ' system hiredis will be used\n'
++ 'to use the bundled hiredis sources instead,'
++ ' run "git submodule update --init"')
++
++
+ def get_sources():
+- hiredis_sources = ("alloc", "async", "hiredis", "net", "read", "sds", "sockcompat")
+- return sorted(glob.glob("src/*.c") + ["vendor/hiredis/%s.c" % src for src in hiredis_sources])
++ return sorted(glob.glob("src/*.c") + get_hiredis_bundled_sources())
+
+
+ def get_linker_args():
+ if 'win32' in sys.platform or 'darwin' in sys.platform:
+ return []
+ else:
+- return ["-Wl,-Bsymbolic", ]
++ return ["-Wl,-Bsymbolic", ] + \
++ ['-lhiredis'] if not is_hiredis_bundled() else []
+
+
+ def get_compiler_args():
+
+base-commit: 8adb1b3cb38b82cdc73fa2d72879712da1f74e70
+--
+2.39.1
+