Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.py: Fallback to use the system hiredis library. #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import importlib
import glob
import io
import os
import sys


Expand All @@ -17,16 +18,39 @@ def version():
return module.__version__


def is_hiredis_bundled():
hiredis_submodule = 'vendor/hiredis'
Apteryks marked this conversation as resolved.
Show resolved Hide resolved
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]
Apteryks marked this conversation as resolved.
Show resolved Hide resolved
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())
Apteryks marked this conversation as resolved.
Show resolved Hide resolved


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():
Expand Down
Loading