mirror of
https://github.com/k2-fsa/sherpa-onnx.git
synced 2026-11-10 13:04:05 +08:00
345 lines
9.4 KiB
YAML
345 lines
9.4 KiB
YAML
name: build-wheels-macos-x64
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- wheel
|
|
workflow_dispatch:
|
|
inputs:
|
|
publish_sherpa_onnx_bin:
|
|
description: "Publish sherpa-onnx-bin"
|
|
required: false
|
|
default: "true"
|
|
type: boolean
|
|
|
|
env:
|
|
SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
|
|
|
|
concurrency:
|
|
group: build-wheels-macos-x64-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
core:
|
|
runs-on: ${{ matrix.os }}
|
|
name: core
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Update version
|
|
shell: bash
|
|
run: |
|
|
./new-release.sh
|
|
git diff .
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.10"
|
|
|
|
- name: Install deps
|
|
shell: bash
|
|
run: |
|
|
python3 -m pip install setuptools wheel twine
|
|
|
|
- name: ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2
|
|
with:
|
|
key: macos-latest-sherpa-onnx-core-x64
|
|
|
|
- name: Configure CMake
|
|
shell: bash
|
|
run: |
|
|
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
|
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
|
cmake --version
|
|
|
|
mkdir build
|
|
cd build
|
|
|
|
cmake \
|
|
-DSHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON \
|
|
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
|
|
-D BUILD_SHARED_LIBS=ON \
|
|
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
|
|
-D CMAKE_BUILD_TYPE=Release \
|
|
-D CMAKE_OSX_ARCHITECTURES='x86_64' \
|
|
-D CMAKE_INSTALL_PREFIX=./install \
|
|
..
|
|
|
|
- name: Build sherpa-onnx for macos
|
|
shell: bash
|
|
run: |
|
|
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
|
|
|
cd build
|
|
make -j2
|
|
make install
|
|
|
|
ls -lh lib
|
|
ls -lh bin
|
|
|
|
file ./bin/sherpa-onnx
|
|
|
|
rm -fv ./install/include/cargs.h
|
|
rm -fv ./install/lib/cargs.h
|
|
rm -fv ./install/lib/libcargs.dylib
|
|
rm -fv ./install/lib/libcargs.a
|
|
rm -rfv ./install/lib/pkgconfig
|
|
|
|
- name: Copy files
|
|
shell: bash
|
|
run: |
|
|
echo 'sherpa-onnx-core'
|
|
mkdir -p scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
|
|
cp -v ./build/install/lib/lib* ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
|
|
|
|
mkdir -p ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
|
|
cp -v ./build/install/include/sherpa-onnx/c-api/*.h ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
|
|
|
|
echo 'sherpa-onnx-bin'
|
|
|
|
mkdir -p ./scripts/wheel/sherpa-onnx-bin/bin
|
|
cp -v ./build/install/bin/sherpa-onnx* ./scripts/wheel/sherpa-onnx-bin/bin
|
|
|
|
- name: Build sherpa-onnx-core
|
|
shell: bash
|
|
run: |
|
|
pushd ./scripts/wheel/sherpa-onnx-core
|
|
python3 setup.py bdist_wheel --plat-name=macosx_10_15_x86_64
|
|
|
|
ls -lh dist
|
|
unzip -l dist/*.whl
|
|
|
|
popd
|
|
|
|
- name: Build sherpa-onnx-bin
|
|
shell: bash
|
|
run: |
|
|
pushd ./scripts/wheel/sherpa-onnx-bin
|
|
python3 setup.py bdist_wheel --plat-name=macosx_10_15_x86_64
|
|
|
|
ls -lh dist
|
|
unzip -l dist/*.whl
|
|
|
|
popd
|
|
|
|
- name: Collect wheels
|
|
shell: bash
|
|
run: |
|
|
cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl .
|
|
cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl .
|
|
|
|
ls -lh *.whl
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheels-core-macos-x64
|
|
path: ./*.whl
|
|
|
|
test:
|
|
name: test
|
|
needs: [core]
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Retrieve artifact from macos x64
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: wheels-core-macos-x64
|
|
path: /tmp/wheels
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.10"
|
|
|
|
- name: Show
|
|
shell: bash
|
|
run: |
|
|
ls -lh /tmp/wheels
|
|
|
|
- name: Install
|
|
shell: bash
|
|
run: |
|
|
python3 -m pip install /tmp/wheels/*.whl
|
|
|
|
- name: Show version
|
|
shell: bash
|
|
run: |
|
|
sherpa-onnx-version
|
|
|
|
- name: Show help
|
|
shell: bash
|
|
run: |
|
|
sherpa-onnx --help
|
|
|
|
ls -lh $(which sherpa-onnx)
|
|
file $(which sherpa-onnx)
|
|
otool -L $(which sherpa-onnx)
|
|
otool -l $(which sherpa-onnx)
|
|
|
|
echo "---"
|
|
|
|
sherpa-onnx-offline --help
|
|
|
|
echo "---"
|
|
|
|
sherpa-onnx-vad --help
|
|
|
|
- name: Publish to huggingface
|
|
env:
|
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
max_attempts: 20
|
|
timeout_seconds: 200
|
|
shell: bash
|
|
command: |
|
|
git config --global user.email "csukuangfj@gmail.com"
|
|
git config --global user.name "Fangjun Kuang"
|
|
|
|
rm -rf huggingface
|
|
export GIT_LFS_SKIP_SMUDGE=1
|
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
|
|
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
|
|
|
d=cpu/$SHERPA_ONNX_VERSION
|
|
|
|
git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels huggingface
|
|
cd huggingface
|
|
git fetch
|
|
git pull
|
|
git merge -m "merge remote" --ff origin main
|
|
|
|
mkdir -p $d
|
|
|
|
cp -v /tmp/wheels/*.whl $d/
|
|
|
|
git status
|
|
git add .
|
|
git commit -m "add more wheels"
|
|
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels main
|
|
|
|
- name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
|
|
if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
|
|
env:
|
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
shell: bash
|
|
run: |
|
|
python3 -m pip install wheel twine==5.0.0 setuptools
|
|
|
|
twine upload --skip-existing --verbose /tmp/wheels/*.whl
|
|
|
|
build_wheels_macos_x64:
|
|
needs: [core, test]
|
|
name: ${{ matrix.python-version }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest]
|
|
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Update version
|
|
shell: bash
|
|
run: |
|
|
./new-release.sh
|
|
git diff .
|
|
|
|
- name: Set macOS deployment target
|
|
run: echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV
|
|
|
|
- name: Build wheels
|
|
uses: pypa/cibuildwheel@v3.3.1
|
|
env:
|
|
CIBW_BUILD: "${{ matrix.python-version}}-* "
|
|
CIBW_ENVIRONMENT: >
|
|
MACOSX_DEPLOYMENT_TARGET=10.15
|
|
SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
|
|
SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='x86_64' -DSHERPA_ONNX_ENABLE_BINARY=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET='10.15' -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF"
|
|
|
|
CIBW_ARCHS: "x86_64"
|
|
CIBW_BUILD_VERBOSITY: 3
|
|
|
|
# Don't repair macOS wheels
|
|
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
|
|
|
|
- name: Display wheels
|
|
shell: bash
|
|
run: |
|
|
ls -lh ./wheelhouse/
|
|
unzip -l ./wheelhouse/*.whl
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheel-macos-x64-${{ matrix.python-version }}
|
|
path: ./wheelhouse/*.whl
|
|
|
|
- name: Publish to huggingface
|
|
env:
|
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
max_attempts: 20
|
|
timeout_seconds: 200
|
|
shell: bash
|
|
command: |
|
|
git config --global user.email "csukuangfj@gmail.com"
|
|
git config --global user.name "Fangjun Kuang"
|
|
|
|
rm -rf huggingface
|
|
export GIT_LFS_SKIP_SMUDGE=1
|
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
|
|
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
|
|
|
d=cpu/$SHERPA_ONNX_VERSION
|
|
|
|
git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels huggingface
|
|
cd huggingface
|
|
git fetch
|
|
git pull
|
|
git merge -m "merge remote" --ff origin main
|
|
|
|
mkdir -p $d
|
|
|
|
cp -v ../wheelhouse/*.whl $d/
|
|
|
|
git status
|
|
git add .
|
|
git commit -m "add more wheels"
|
|
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels main
|
|
|
|
- name: Publish wheels to PyPI
|
|
env:
|
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
run: |
|
|
opts='--break-system-packages'
|
|
|
|
python3 -m pip install $opts wheel twine==5.0.0 setuptools
|
|
|
|
twine upload --skip-existing --verbose ./wheelhouse/*.whl
|