@@ -134,6 +134,31 @@ def __init__(self, ext):
134
134
self .ext = ext
135
135
136
136
137
+ def get_subdriname (directory_path ):
138
+ try :
139
+ # List only subdirectories in the given directory
140
+ subdirectories = [name for dir in directory_path for name in os .listdir (dir )
141
+ if os .path .isdir (os .path .join (directory_path , name ))]
142
+ return subdirectories
143
+ except Exception :
144
+ return []
145
+
146
+ def get_libev_headers_path ():
147
+ libev_hb_paths = ["/opt/homebrew/Cellar/libev" , os .path .expanduser ('~/homebrew/Cellar/libev' )]
148
+ for hb_path in libev_hb_paths :
149
+ if not os .path .exists (hb_path ):
150
+ continue
151
+ versions = [dir for dir in get_subdriname (hb_path ) if dir [0 ] in "0123456789" ]
152
+ if not versions :
153
+ continue
154
+ picked_version = sorted (versions , reverse = True )[0 ]
155
+ resulted_path = os .path .join (hb_path , picked_version , 'include' )
156
+ warnings .warn ("found libev headers in '%s'" % resulted_path )
157
+ return [resulted_path ]
158
+ warnings .warn ("did not find libev headers in '%s'" % libev_hb_paths )
159
+ return []
160
+
161
+
137
162
murmur3_ext = Extension ('cassandra.cmurmur3' ,
138
163
sources = ['cassandra/cmurmur3.c' ])
139
164
@@ -142,7 +167,7 @@ def __init__(self, ext):
142
167
libev_includes = ['/usr/include/libev' , '/usr/local/include' , '/opt/local/include' , '/usr/include' ]
143
168
libev_libdirs = ['/usr/local/lib' , '/opt/local/lib' , '/usr/lib64' ]
144
169
if is_macos :
145
- libev_includes .extend (['/opt/homebrew/include' , os .path .expanduser ('~/homebrew/include' )])
170
+ libev_includes .extend (['/opt/homebrew/include' , os .path .expanduser ('~/homebrew/include' ), * get_libev_headers_path () ])
146
171
libev_libdirs .extend (['/opt/homebrew/lib' ])
147
172
148
173
conan_envfile = Path (__file__ ).parent / 'build-release/conan/conandeps.env'
@@ -153,9 +178,9 @@ def __init__(self, ext):
153
178
154
179
libev_ext = Extension ('cassandra.io.libevwrapper' ,
155
180
sources = ['cassandra/io/libevwrapper.c' ],
156
- include_dirs = ['/usr/include/libev' , '/usr/local/include' , '/opt/local/include' ],
181
+ include_dirs = libev_includes + ['/usr/include/libev' , '/usr/local/include' , '/opt/local/include' ],
157
182
libraries = ['ev' ],
158
- library_dirs = ['/usr/local/lib' , '/opt/local/lib' ])
183
+ library_dirs = libev_libdirs + ['/usr/local/lib' , '/opt/local/lib' ])
159
184
160
185
platform_unsupported_msg = \
161
186
"""
0 commit comments