Skip to content

Commit

Permalink
Enable build 2.3 for macosx
Browse files Browse the repository at this point in the history
Signed-off-by: Ji Bin <[email protected]>
  • Loading branch information
matrixji committed Apr 12, 2023
1 parent ebde742 commit 930e98d
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 79 deletions.
166 changes: 89 additions & 77 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
CCACHE_COMPRESS: 1
CCACHE_COMPRESSLEVEL: 5
CCACHE_MAXSIZE: 2G
timeout-minutes: 120
timeout-minutes: 180
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -62,55 +62,55 @@ jobs:
name: wheel_linux
path: dist/*.whl
retention-days: 5
# build_macos:
# name: Build Wheel - macOS
# runs-on: macos-11
# env:
# CCACHE_DIR: ${{ github.workspace }}/.ccache
# CCACHE_COMPILERCHECK: content
# CCACHE_COMPRESS: 1
# CCACHE_COMPRESSLEVEL: 5
# CCACHE_MAXSIZE: 2G
# timeout-minutes: 120
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Cache go
# uses: actions/cache@v3
# with:
# path: |
# ~/.cache/go-build
# ~/go/pkg/mod
# key: macos-go-${{ hashFiles('milvus_binary/env.sh') }}
# restore-keys: macos-go-
# - name: Cache conan
# uses: actions/cache@v3
# with:
# path: |
# ~/.conan/data
# key: macos-conan-${{ hashFiles('milvus_binary/env.sh') }}
# restore-keys: macos-conan-
# - name: Cache ccache
# uses: actions/cache@v3
# with:
# path: |
# ${{ github.workspace }}/.ccache
# key: macos-ccache-${{ hashFiles('milvus_binary/env.sh') }}
# restore-keys: macos-ccache-
# - name: Setup Go environment
# uses: actions/setup-go@v4
# with:
# go-version: '~1.18.10'
# cache: false
# - name: Build Wheel
# run: |
# python3 -m pip install --user build wheel 'setuptools>64.0'
# python3 -m build -w -n
# - uses: actions/upload-artifact@v3
# with:
# name: wheel_macos
# path: dist/*.whl
# retention-days: 5
build_macos:
name: Build Wheel - macOS
runs-on: macos-11
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPILERCHECK: content
CCACHE_COMPRESS: 1
CCACHE_COMPRESSLEVEL: 5
CCACHE_MAXSIZE: 2G
timeout-minutes: 180
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache go
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: macos-go-${{ hashFiles('milvus_binary/env.sh') }}
restore-keys: macos-go-
- name: Cache conan
uses: actions/cache@v3
with:
path: |
~/.conan/data
key: macos-conan-${{ hashFiles('milvus_binary/env.sh') }}
restore-keys: macos-conan-
- name: Cache ccache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.ccache
key: macos-ccache-${{ hashFiles('milvus_binary/env.sh') }}
restore-keys: macos-ccache-
- name: Setup Go environment
uses: actions/setup-go@v4
with:
go-version: '~1.18.10'
cache: false
- name: Build Wheel
run: |
python3 -m pip install --user build wheel 'setuptools>64.0'
python3 -m build -w -n
- uses: actions/upload-artifact@v3
with:
name: wheel_macos
path: dist/*.whl
retention-days: 5
# build_windows:
# name: Build Wheel - windows
# runs-on: windows-latest
Expand All @@ -120,7 +120,7 @@ jobs:
# CCACHE_COMPRESS: 1
# CCACHE_COMPRESSLEVEL: 5
# CCACHE_MAXSIZE: 2G
# timeout-minutes: 120
# timeout-minutes: 180
# steps:
# - name: Set git to use LF
# run: |
Expand Down Expand Up @@ -210,31 +210,43 @@ jobs:
python3 -m pip install --user "$(echo dist/*.whl)[client]"
cd examples
python3 example.py
# acceptance_test_macos:
# needs:
# - build_macos
# name: Acceptance Test ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# timeout-minutes: 60
# strategy:
# fail-fast: false
# matrix:
# os: ["macos-11", "macos-12"]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: '3.8'
# - uses: actions/download-artifact@v3
# with:
# name: wheel_macos
# path: dist
# - name: Run hello milvus
# run: |
# python3 -m pip install --user wheel setuptools
# python3 -m pip install --user "$(echo dist/*.whl)[client]"
# cd examples
# python3 example.py
- name: Upload runtime log
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: milvus-log
path: ~/.milvus.io/milvus-server/**/*.log
acceptance_test_macos:
needs:
- build_macos
name: Acceptance Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: ["macos-11", "macos-12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: actions/download-artifact@v3
with:
name: wheel_macos
path: dist
- name: Run hello milvus
run: |
python3 -m pip install --user wheel setuptools
python3 -m pip install --user "$(echo dist/*.whl)[client]"
cd examples
python3 example.py
- name: Upload runtime log
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: milvus-log
path: ~/.milvus.io/milvus-server/**/*.log
# acceptance_test_windows:
# needs:
# - build_windows
Expand All @@ -259,4 +271,4 @@ jobs:
# $x = Get-ChildItem dist\*.whl
# pip install "$x[client]"
# cd examples
# python example.py
# python example.py
4 changes: 2 additions & 2 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# 5. search

# Optional, if you want store all related data to specific location
# default it wil using %APPDATA%/milvus-io/milvus-server
default_server.set_base_dir('test_milvus')
# default it wil using ~/.milvus-io/milvus-server/<__version_of_milvus__>
# default_server.set_base_dir('test_milvus')

# Optional, if you want cleanup previous data
default_server.cleanup()
Expand Down
64 changes: 64 additions & 0 deletions milvus_binary/patches/macosx-v2.3.0-beta.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/scripts/core_build.sh b/scripts/core_build.sh
index 5d079c317..2eccfbd0b 100755
--- a/scripts/core_build.sh
+++ b/scripts/core_build.sh
@@ -193,12 +193,24 @@ conan remote add default-conan-local https://milvus01.jfrog.io/artifactory/api/c
unameOut="$(uname -s)"
case "${unameOut}" in
Darwin*)
- llvm_prefix="$(brew --prefix llvm)"
+ # detect llvm version by valid list
+ for llvm_version in 15 14 NOT_FOUND ; do
+ if brew ls --versions llvm@${llvm_version} > /dev/null; then
+ break
+ fi
+ done
+ if [ "${llvm_version}" = "NOT_FOUND" ] ; then
+ echo "llvm@14~15 is not installed"
+ exit 1
+ fi
+ llvm_prefix="$(brew --prefix llvm@${llvm_version})"
export CLANG_TOOLS_PATH="${llvm_prefix}/bin"
+ export PATH=${CLANG_TOOLS_PATH}:${PATH}
export CC="${llvm_prefix}/bin/clang"
export CXX="${llvm_prefix}/bin/clang++"
- export CFLAGS=-Wno-deprecated-declarations
- export CXXFLAGS=-Wno-deprecated-declarations
+ export CFLAGS="-Wno-deprecated-declarations -I$(brew --prefix libomp)/include"
+ export CXXFLAGS=${CFLAGS}
+ export LDFLAGS="-L$(brew --prefix libomp)/lib"
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler=clang -s compiler.version=15 -s compiler.libcxx=libc++ || { echo 'conan install failed'; exit 1; }
;;
Linux*)
diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh
index 93a81669d..5c5440880 100755
--- a/scripts/install_deps.sh
+++ b/scripts/install_deps.sh
@@ -50,25 +50,10 @@ function install_linux_deps() {

function install_mac_deps() {
sudo xcode-select --install > /dev/null 2>&1
- brew install libomp ninja cmake llvm ccache grep
- export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
- brew update && brew upgrade && brew cleanup
+ brew install libomp ninja cmake llvm@15 ccache pkg-config openssl librdkafka
+ brew install grep

pip3 install conan==1.58.0
-
- if [[ $(arch) == 'arm64' ]]; then
- brew install openssl
- brew install librdkafka
- brew install pkg-config
- sudo mkdir /usr/local/include
- sudo mkdir /usr/local/opt
- sudo ln -s "$(brew --prefix llvm)" "/usr/local/opt/llvm"
- sudo ln -s "$(brew --prefix libomp)/include/omp.h" "/usr/local/include/omp.h"
- sudo ln -s "$(brew --prefix libomp)" "/usr/local/opt/libomp"
- sudo ln -s "$(brew --prefix boost)/include/boost" "/usr/local/include/boost"
- sudo ln -s "$(brew --prefix tbb)/include/tbb" "/usr/local/include/tbb"
- sudo ln -s "$(brew --prefix tbb)/include/oneapi" "/usr/local/include/oneapi"
- fi
}

if ! command -v go &> /dev/null

0 comments on commit 930e98d

Please sign in to comment.