Skip to content

Commit

Permalink
cicd: fix macos builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dkropachev committed Jan 26, 2025
1 parent f7cf0f3 commit e0a0b8e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- os: windows-latest
platform: PyPy

- os: macos-latest
- os: macos-14
platform: all

- os: macos-13
Expand Down Expand Up @@ -112,8 +112,15 @@ jobs:
run: |
echo "CIBW_BUILD=cp39* cp310* cp311* cp312* cp313*" >> $GITHUB_ENV
echo "CIBW_BEFORE_TEST_MACOS=pip install -r {project}/test-requirements.txt pytest" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV
if [ "${{ matrix.os }}" == "macos-13" ]; then
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV;
echo "Enforcing target deployment for 13.0"
elif [ "${{ matrix.os }}" == "macos-14" ]; then
echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> $GITHUB_ENV;
echo "Enforcing target deployment for 14.0"
else
echo "Unknown macos version" && false;
fi
- name: Overwrite for MacOs PyPy
if: runner.os == 'MacOs' && matrix.platform == 'PyPy'
run: |
Expand Down
31 changes: 28 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ def __init__(self, ext):
self.ext = ext


def get_subdriname(directory_path):
try:
# List only subdirectories in the given directory
subdirectories = [name for dir in directory_path for name in os.listdir(dir)
if os.path.isdir(os.path.join(directory_path, name))]
return subdirectories
except Exception:
return []

def get_libev_headers_path():
libev_hb_paths = ["/opt/homebrew/Cellar/libev", os.path.expanduser('~/homebrew/Cellar/libev')]
for hb_path in libev_hb_paths:
if not os.path.exists(hb_path):
continue
versions = [dir for dir in get_subdriname(hb_path) if dir[0] in "0123456789"]
if not versions:
continue
picked_version = sorted(versions, reverse=True)[0]
resulted_path = os.path.join(hb_path, picked_version, 'include')
warnings.warn("found libev headers in '%s'" % resulted_path)
return [resulted_path]
warnings.warn("did not find libev headers in '%s'" % libev_hb_paths)
return []


murmur3_ext = Extension('cassandra.cmurmur3',
sources=['cassandra/cmurmur3.c'])

Expand All @@ -142,7 +167,7 @@ def __init__(self, ext):
libev_includes = ['/usr/include/libev', '/usr/local/include', '/opt/local/include', '/usr/include']
libev_libdirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
if is_macos:
libev_includes.extend(['/opt/homebrew/include', os.path.expanduser('~/homebrew/include')])
libev_includes.extend(['/opt/homebrew/include', os.path.expanduser('~/homebrew/include'), *get_libev_headers_path()])
libev_libdirs.extend(['/opt/homebrew/lib'])

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

libev_ext = Extension('cassandra.io.libevwrapper',
sources=['cassandra/io/libevwrapper.c'],
include_dirs=['/usr/include/libev', '/usr/local/include', '/opt/local/include'],
include_dirs=libev_includes+['/usr/include/libev', '/usr/local/include', '/opt/local/include'],
libraries=['ev'],
library_dirs=['/usr/local/lib', '/opt/local/lib'])
library_dirs=libev_libdirs+['/usr/local/lib', '/opt/local/lib'])

platform_unsupported_msg = \
"""
Expand Down

0 comments on commit e0a0b8e

Please sign in to comment.