Skip to content

Commit e0a0b8e

Browse files
committed
cicd: fix macos builds
1 parent f7cf0f3 commit e0a0b8e

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

.github/workflows/build-push.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- os: windows-latest
4141
platform: PyPy
4242

43-
- os: macos-latest
43+
- os: macos-14
4444
platform: all
4545

4646
- os: macos-13
@@ -112,8 +112,15 @@ jobs:
112112
run: |
113113
echo "CIBW_BUILD=cp39* cp310* cp311* cp312* cp313*" >> $GITHUB_ENV
114114
echo "CIBW_BEFORE_TEST_MACOS=pip install -r {project}/test-requirements.txt pytest" >> $GITHUB_ENV
115-
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV
116-
115+
if [ "${{ matrix.os }}" == "macos-13" ]; then
116+
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV;
117+
echo "Enforcing target deployment for 13.0"
118+
elif [ "${{ matrix.os }}" == "macos-14" ]; then
119+
echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> $GITHUB_ENV;
120+
echo "Enforcing target deployment for 14.0"
121+
else
122+
echo "Unknown macos version" && false;
123+
fi
117124
- name: Overwrite for MacOs PyPy
118125
if: runner.os == 'MacOs' && matrix.platform == 'PyPy'
119126
run: |

setup.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,31 @@ def __init__(self, ext):
134134
self.ext = ext
135135

136136

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+
137162
murmur3_ext = Extension('cassandra.cmurmur3',
138163
sources=['cassandra/cmurmur3.c'])
139164

@@ -142,7 +167,7 @@ def __init__(self, ext):
142167
libev_includes = ['/usr/include/libev', '/usr/local/include', '/opt/local/include', '/usr/include']
143168
libev_libdirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
144169
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()])
146171
libev_libdirs.extend(['/opt/homebrew/lib'])
147172

148173
conan_envfile = Path(__file__).parent / 'build-release/conan/conandeps.env'
@@ -153,9 +178,9 @@ def __init__(self, ext):
153178

154179
libev_ext = Extension('cassandra.io.libevwrapper',
155180
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'],
157182
libraries=['ev'],
158-
library_dirs=['/usr/local/lib', '/opt/local/lib'])
183+
library_dirs=libev_libdirs+['/usr/local/lib', '/opt/local/lib'])
159184

160185
platform_unsupported_msg = \
161186
"""

0 commit comments

Comments
 (0)