| 1 | Upstream status: https://github.com/redis/hiredis-py/pull/161
|
| 2 |
|
| 3 | From 7b3c8a364f6167f4b1828dd9c48ada3d8b0786f6 Mon Sep 17 00:00:00 2001
|
| 4 | From: Maxim Cournoyer <[email protected]>
|
| 5 | Date: Sat, 18 Mar 2023 21:32:21 -0400
|
| 6 | Subject: [PATCH] setup.py: Fallback to use the system hiredis library.
|
| 7 |
|
| 8 | Fixes #158 fully, including using a system-prodived hiredis.
|
| 9 |
|
| 10 | When the hiredis git submodule hasn't been initialized, print a
|
| 11 | message about it, and attempt to link against the a system-provided
|
| 12 | hiredis library instead.
|
| 13 |
|
| 14 | * setup.py (is_hiredis_bundled): New procedure.
|
| 15 | (get_hiredis_bundled_sources): Likewise. Print a message when
|
| 16 | bundled_hiredis_sources is empty.
|
| 17 | (get_sources): Adjust to use the above procedure.
|
| 18 | (get_linker_args): Add -lhiredis when the bundled hiredis is not used.
|
| 19 | ---
|
| 20 | setup.py | 30 +++++++++++++++++++++++++++---
|
| 21 | 1 file changed, 27 insertions(+), 3 deletions(-)
|
| 22 |
|
| 23 | diff --git a/setup.py b/setup.py
|
| 24 | index 905df59..a77aca3 100644
|
| 25 | |
| 26 | |
| 27 | @@ -7,6 +7,7 @@ except ImportError:
|
| 28 | import importlib
|
| 29 | import glob
|
| 30 | import io
|
| 31 | +import os
|
| 32 | import sys
|
| 33 |
|
| 34 |
|
| 35 | @@ -17,16 +18,39 @@ def version():
|
| 36 | return module.__version__
|
| 37 |
|
| 38 |
|
| 39 | +def is_hiredis_bundled():
|
| 40 | + hiredis_submodule = 'vendor/hiredis'
|
| 41 | + if (os.path.exists(hiredis_submodule)
|
| 42 | + and not os.path.isfile(hiredis_submodule)):
|
| 43 | + return not os.listdir()
|
| 44 | + return False
|
| 45 | +
|
| 46 | +
|
| 47 | +def get_hiredis_bundled_sources():
|
| 48 | + hiredis_sources = ("alloc", "async", "hiredis", "net", "read",
|
| 49 | + "sds", "sockcompat")
|
| 50 | + if is_hiredis_bundled():
|
| 51 | + return ["vendor/hiredis/%s.c" % src for src in hiredis_sources]
|
| 52 | + return []
|
| 53 | +
|
| 54 | +
|
| 55 | +if not is_hiredis_bundled():
|
| 56 | + print('the bundled hiredis sources were not found;'
|
| 57 | + ' system hiredis will be used\n'
|
| 58 | + 'to use the bundled hiredis sources instead,'
|
| 59 | + ' run "git submodule update --init"')
|
| 60 | +
|
| 61 | +
|
| 62 | def get_sources():
|
| 63 | - hiredis_sources = ("alloc", "async", "hiredis", "net", "read", "sds", "sockcompat")
|
| 64 | - return sorted(glob.glob("src/*.c") + ["vendor/hiredis/%s.c" % src for src in hiredis_sources])
|
| 65 | + return sorted(glob.glob("src/*.c") + get_hiredis_bundled_sources())
|
| 66 |
|
| 67 |
|
| 68 | def get_linker_args():
|
| 69 | if 'win32' in sys.platform or 'darwin' in sys.platform:
|
| 70 | return []
|
| 71 | else:
|
| 72 | - return ["-Wl,-Bsymbolic", ]
|
| 73 | + return ["-Wl,-Bsymbolic", ] + \
|
| 74 | + ['-lhiredis'] if not is_hiredis_bundled() else []
|
| 75 |
|
| 76 |
|
| 77 | def get_compiler_args():
|
| 78 |
|
| 79 | base-commit: 8adb1b3cb38b82cdc73fa2d72879712da1f74e70
|
| 80 | --
|
| 81 | 2.39.1
|
| 82 |
|