mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 11:35:02 -05:00
feat(ci): release concrete-python on mac
support both M1 and x86 for 3.8, 3.9, and 3.10
This commit is contained in:
@@ -132,8 +132,123 @@ jobs:
|
||||
|
||||
deactivate
|
||||
|
||||
macos:
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8", "3.9", "3.10"]
|
||||
runs-on: ["aws-mac1-metal", "m1mac"]
|
||||
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
steps:
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.7.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.CONCRETE_CI_SSH_PRIVATE }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
|
||||
|
||||
- name: Install OS Dependencies
|
||||
run: |
|
||||
brew install ninja ccache
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- name: Set release version
|
||||
run: echo "__version__ = \"$(date +"%Y.%m.%d")\"" >| frontends/concrete-python/version.txt
|
||||
|
||||
- name: Create build directory
|
||||
run: mkdir build
|
||||
|
||||
- name: Build wheel
|
||||
run: |
|
||||
set -e
|
||||
|
||||
cd frontends/concrete-python
|
||||
|
||||
rm -rf .venv
|
||||
${{ format('python{0}', matrix.python-version) }} -m venv .venv
|
||||
|
||||
. .venv/bin/activate
|
||||
|
||||
pip install -r requirements.dev.txt
|
||||
pip install -r requirements.txt
|
||||
|
||||
cd $GITHUB_WORKSPACE/compilers/concrete-compiler/compiler
|
||||
|
||||
echo "Debug: ccache statistics (prior to the build):"
|
||||
ccache -s
|
||||
|
||||
make Python3_EXECUTABLE=$(which python) python-bindings
|
||||
|
||||
echo "Debug: ccache statistics (after the build):"
|
||||
ccache -s
|
||||
|
||||
export COMPILER_BUILD_DIRECTORY=$(pwd)/build
|
||||
cd $GITHUB_WORKSPACE/frontends/concrete-python
|
||||
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
|
||||
pip wheel -v --no-deps -w dist .
|
||||
delocate-wheel -v dist/*macos*.whl
|
||||
|
||||
deactivate
|
||||
|
||||
- name: Upload wheel
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ format('wheel-{0}-{1}', matrix.python-version, matrix.runs-on) }}
|
||||
path: frontends/concrete-python/dist/*macos*.whl
|
||||
retention-days: 3
|
||||
|
||||
- name: Test wheel
|
||||
run: |
|
||||
set -e
|
||||
|
||||
export CONCRETE_PYTHON=$(pwd)/frontends/concrete-python
|
||||
|
||||
cd $(mktemp -d)
|
||||
|
||||
export PYTHON_VERSION=${{ format('python{0}', matrix.python-version) }}
|
||||
|
||||
$PYTHON_VERSION -m venv .testenv
|
||||
source .testenv/bin/activate
|
||||
|
||||
pip install $CONCRETE_PYTHON/dist/*macos*.whl
|
||||
pip install -r $CONCRETE_PYTHON/requirements.dev.txt
|
||||
|
||||
# MacOS x86 have conflict between our OpenMP library, and one from torch
|
||||
# we fix it by using a single one (from torch)
|
||||
# see discussion: https://discuss.python.org/t/conflicting-binary-extensions-in-different-packages/25332/8
|
||||
export SITE_PACKAGES=$(pwd)/.testenv/lib/$PYTHON_VERSION/site-packages/
|
||||
export CONCRETE_LIB_OMP=$SITE_PACKAGES/concrete/.dylibs/libomp.dylib
|
||||
# Where is libiomp? Possibilities ordered in increasing priorities
|
||||
export TORCH_LIB_IOMP="this shouldn't exist"
|
||||
ls $SITE_PACKAGES/torch/lib/libiomp5.dylib && export TORCH_LIB_IOMP=$SITE_PACKAGES/torch/lib/libiomp5.dylib
|
||||
ls $SITE_PACKAGES/torch/.dylibs/libiomp5.dylib && export TORCH_LIB_IOMP=$SITE_PACKAGES/torch/.dylibs/libiomp5.dylib
|
||||
ls $SITE_PACKAGES/functorch/.dylibs/libiomp5.dylib && export TORCH_LIB_IOMP=$SITE_PACKAGES/functorch/.dylibs/libiomp5.dylib
|
||||
ls $TORCH_LIB_IOMP \
|
||||
&& rm $CONCRETE_LIB_OMP \
|
||||
&& ln -s $TORCH_LIB_IOMP $CONCRETE_LIB_OMP
|
||||
|
||||
cp -R $CONCRETE_PYTHON/tests .
|
||||
cp -R $CONCRETE_PYTHON/pytest.ini .
|
||||
|
||||
pytest tests -svv -n auto -m "not dataflow"
|
||||
|
||||
deactivate
|
||||
|
||||
push:
|
||||
needs: linux-x86
|
||||
needs: [linux-x86, macos]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
@@ -151,6 +266,36 @@ jobs:
|
||||
name: wheel-3.10-linux-x86
|
||||
path: wheels
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheel-3.8-aws-mac1-metal
|
||||
path: wheels
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheel-3.9-aws-mac1-metal
|
||||
path: wheels
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheel-3.10-aws-mac1-metal
|
||||
path: wheels
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheel-3.8-m1mac
|
||||
path: wheels
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheel-3.9-m1mac
|
||||
path: wheels
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheel-3.10-m1mac
|
||||
path: wheels
|
||||
|
||||
- name: Push wheels to internal PyPI
|
||||
run: |
|
||||
pip install twine==4.0.2
|
||||
|
||||
Reference in New Issue
Block a user