Skip to content

Commit d05e9d3

Browse files
authored
PYTHON-1386 Make libev extension consistent with other extensions and allow specifying of libev install via env vars (#1223)
1 parent 6f621ad commit d05e9d3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

setup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,14 @@ def __init__(self, ext):
120120
murmur3_ext = Extension('cassandra.cmurmur3',
121121
sources=['cassandra/cmurmur3.c'])
122122

123-
libev_includes = ['/usr/include/libev', '/usr/local/include', '/opt/local/include', '/usr/include']
124-
libev_libdirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
123+
def eval_env_var_as_array(varname):
124+
val = os.environ.get(varname)
125+
return None if not val else [v.strip() for v in val.split(',')]
126+
127+
DEFAULT_LIBEV_INCLUDES = ['/usr/include/libev', '/usr/local/include', '/opt/local/include', '/usr/include']
128+
DEFAULT_LIBEV_LIBDIRS = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
129+
libev_includes = eval_env_var_as_array('CASS_DRIVER_LIBEV_INCLUDES') or DEFAULT_LIBEV_INCLUDES
130+
libev_libdirs = eval_env_var_as_array('CASS_DRIVER_LIBEV_LIBS') or DEFAULT_LIBEV_LIBDIRS
125131
if is_macos:
126132
libev_includes.extend(['/opt/homebrew/include', os.path.expanduser('~/homebrew/include')])
127133
libev_libdirs.extend(['/opt/homebrew/lib'])
@@ -165,7 +171,7 @@ def __init__(self, ext):
165171

166172
try_extensions = "--no-extensions" not in sys.argv and is_supported_platform and is_supported_arch and not os.environ.get('CASS_DRIVER_NO_EXTENSIONS')
167173
try_murmur3 = try_extensions and "--no-murmur3" not in sys.argv
168-
try_libev = try_extensions and "--no-libev" not in sys.argv and not is_pypy and not is_windows
174+
try_libev = try_extensions and "--no-libev" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_LIBEV')
169175
try_cython = try_extensions and "--no-cython" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_CYTHON')
170176
try_cython &= 'egg_info' not in sys.argv # bypass setup_requires for pip egg_info calls, which will never have --install-option"--no-cython" coming fomr pip
171177

@@ -280,6 +286,7 @@ def _setup_extensions(self):
280286
self.extensions.append(murmur3_ext)
281287

282288
if try_libev:
289+
sys.stderr.write("Appending libev extension %s" % libev_ext)
283290
self.extensions.append(libev_ext)
284291

285292
if try_cython:

0 commit comments

Comments
 (0)