Fangjun Kuang
Committed by GitHub

Split sherpa-onnx Python package (#2521)

正在显示 41 个修改的文件 包含 2292 行增加244 行删除
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,7 +20,277 @@ concurrency:
cancel-in-progress: true
jobs:
core:
name: core
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04-arm]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: Display PWD
shell: bash
run: |
echo "pwd: $PWD"
ls -lh
du -h -d1 .
- name: Build sherpa-onnx
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/manylinux2014_aarch64
options: |
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
shell: bash
run: |
uname -a
gcc --version
cmake --version
cat /etc/*release
id
pwd
cd /home/runner/work/sherpa-onnx/sherpa-onnx
find /opt -name "python*"
echo "--------------------"
export PATH=/opt/_internal/cpython-3.10.18/bin:$PATH
which python3
python3 --version
python3 -m venv my
source ./my/bin/activate
python3 -m pip install setuptools wheel twine
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
pushd alsa-lib
./gitcompile
popd
export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
mkdir build
pushd build
cmake \
-D SHERPA_ONNX_ENABLE_TTS=ON \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-D CMAKE_INSTALL_PREFIX=./install \
..
make -j2
make install
ls -lh lib
ls -lh bin
echo "----"
ls -lh install/lib
rm -fv install/lib/libcargs.so
echo "----"
ls -lh install/bin
echo 'sherpa-onnx-core'
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
cp -v ./install/lib/lib*.so ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
pushd ../scripts/wheel/sherpa-onnx-core
python3 setup.py bdist_wheel --plat-name=manylinux2014_aarch64
ls -lh dist
popd
echo 'sherpa-onnx-bin'
mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
pushd ../scripts/wheel/sherpa-onnx-bin
python3 setup.py bdist_wheel --plat-name=manylinux2014_aarch64
ls -lh dist
popd
- name: Collect wheels
shell: bash
run: |
sudo chown -R $USER ./scripts/wheel
mkdir wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheels-core-linux-aarch64
path: ./wheelhouse/*.whl
- name: Show wheels
shell: bash
run: |
sudo chown -R $USER ./scripts/wheel
ls -lh ./scripts/wheel/sherpa-onnx-core/dist
ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
echo "---"
unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
- name: Install patchelf
shell: bash
run: |
sudo apt-get update -q
sudo apt-get install -q -y patchelf
patchelf --help
- name: Patch wheels
shell: bash
run: |
mkdir ./wheels
sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels
ls -lh ./wheels/
rm -rf ./wheelhouse
mv ./wheels ./wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheels-core-linux-aarch64-patched
path: ./wheelhouse/*.whl
test:
name: test
needs: [core]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04-arm]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from Linux x64
uses: actions/download-artifact@v4
with:
name: wheels-core-linux-aarch64-patched
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
echo "---"
ls -lh $(which sherpa-onnx)
file $(which sherpa-onnx)
readelf -d $(which sherpa-onnx)
ldd $(which sherpa-onnx)
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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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 --upgrade pip
python3 -m pip install wheel twine==5.0.0 setuptools
twine upload /tmp/wheels/*.whl
build_wheels_aarch64:
needs: [core, test]
name: ${{ matrix.manylinux }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
... ... @@ -22,8 +298,8 @@ jobs:
matrix:
# see https://github.com/pypa/cibuildwheel/issues/2257
# we don't use qemu from now on
os: [ubuntu-22.04-arm]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
os: [ubuntu-24.04-arm]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
manylinux: [manylinux2014] #, manylinux_2_28]
steps:
... ... @@ -38,7 +314,7 @@ jobs:
# see https://cibuildwheel.readthedocs.io/en/stable/changelog/
# for a list of versions
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_BEFORE_ALL: |
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
... ... @@ -48,7 +324,15 @@ jobs:
echo "PWD"
ls -lh /project/alsa-lib/src/.libs
CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR SHERPA_ONNX_MAKE_ARGS="VERBOSE=1" SHERPA_ONNX_ENABLE_ALSA=1
CIBW_ENVIRONMENT: >
SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH
SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs
LD_LIBRARY_PATH=/project/build/bdist.linux-aarch64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR
SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
SHERPA_ONNX_ENABLE_ALSA=1
SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_BINARY=OFF -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF"
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
CIBW_BUILD_VERBOSITY: 3
... ... @@ -57,28 +341,38 @@ jobs:
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_aarch64
# From onnxruntime >= 1.17.0, it drops support for CentOS 7.0 and it supports only manylinux_2_28.
# manylinux_2_24 is no longer supported
CIBW_REPAIR_WHEEL_COMMAND: >
auditwheel repair -w {dest_dir}
--exclude libonnxruntime.so
{wheel}
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}-linux-aarch64
path: ./wheelhouse/*.whl
- name: Display wheels
shell: bash
run: |
ls -lh ./wheelhouse/
- name: Install patchelf
- name: Show wheels
shell: bash
run: |
sudo apt-get update -q
sudo apt-get install -q -y patchelf
patchelf --help
ls -lh wheelhouse/*.whl
- name: Patch wheels
shell: bash
run: |
mkdir ./wheels
sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels
unzip -l wheelhouse/*.whl
ls -lh ./wheels/
rm -rf ./wheelhouse
mv ./wheels ./wheelhouse
echo "---"
mkdir t
cp wheelhouse/*.whl ./t
cd ./t
unzip ./*.whl
ls -lh
echo "---"
readelf -d sherpa_onnx/lib/*.so
- name: Publish to huggingface
env:
... ... @@ -116,11 +410,6 @@ jobs:
git commit -m "add more wheels"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}
path: ./wheelhouse/*.whl
- name: Publish wheels to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
... ...
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,19 +20,18 @@ concurrency:
cancel-in-progress: true
jobs:
build_wheels_linux:
name: ${{ matrix.manylinux }} ${{ matrix.python-version }}
core:
name: core
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
manylinux: [manylinux2014] #, manylinux_2_28]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update version
shell: bash
... ... @@ -34,30 +39,127 @@ jobs:
./new-release.sh
git diff .
# see https://cibuildwheel.readthedocs.io/en/stable/changelog/
# for a list of versions
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BEFORE_ALL: |
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
cd alsa-lib
./gitcompile
cd ..
echo "PWD"
ls -lh /project/alsa-lib/src/.libs
- name: Display PWD
shell: bash
run: |
echo "pwd: $PWD"
ls -lh
du -h -d1 .
CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR SHERPA_ONNX_MAKE_ARGS="VERBOSE=1" SHERPA_ONNX_ENABLE_ALSA=1
- name: Build sherpa-onnx
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/manylinux2014_x86_64
options: |
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
shell: bash
run: |
uname -a
gcc --version
cmake --version
cat /etc/*release
id
pwd
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
CIBW_BUILD_VERBOSITY: 3
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_x86_64
cd /home/runner/work/sherpa-onnx/sherpa-onnx
find /opt -name "python*"
echo "--------------------"
export PATH=/opt/_internal/cpython-3.10.18/bin:$PATH
which python3
python3 --version
python3 -m venv my
source ./my/bin/activate
python3 -m pip install setuptools wheel twine
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
pushd alsa-lib
./gitcompile
popd
export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
mkdir build
pushd build
cmake \
-D SHERPA_ONNX_ENABLE_TTS=ON \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-D CMAKE_INSTALL_PREFIX=./install \
..
make -j2
make install
ls -lh lib
ls -lh bin
echo "----"
ls -lh install/lib
rm -fv install/lib/libcargs.so
echo "----"
ls -lh install/bin
echo 'sherpa-onnx-core'
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
cp -v ./install/lib/lib*.so ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
pushd ../scripts/wheel/sherpa-onnx-core
python3 setup.py bdist_wheel --plat-name=manylinux2014_x86_64
ls -lh dist
unzip -l dist/*.whl
popd
echo 'sherpa-onnx-bin'
mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
- name: Display wheels
pushd ../scripts/wheel/sherpa-onnx-bin
python3 setup.py bdist_wheel --plat-name=manylinux2014_x86_64
ls -lh dist
unzip -l dist/*.whl
popd
- name: Collect wheels
shell: bash
run: |
ls -lh ./wheelhouse/
sudo chown -R $USER ./scripts/wheel
mkdir wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheels-core-linux-x64
path: ./wheelhouse/*.whl
- name: Show wheels
shell: bash
run: |
sudo chown -R $USER ./scripts/wheel
ls -lh ./scripts/wheel/sherpa-onnx-core/dist
ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
echo "---"
unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
- name: Install patchelf
shell: bash
... ... @@ -78,9 +180,189 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: wheels-core-linux-x64-patched
path: ./wheelhouse/*.whl
test:
name: test
needs: [core]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from Linux x64
uses: actions/download-artifact@v4
with:
name: wheels-core-linux-x64-patched
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
echo "---"
ls -lh $(which sherpa-onnx)
file $(which sherpa-onnx)
readelf -d $(which sherpa-onnx)
ldd $(which sherpa-onnx)
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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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 --upgrade pip
python3 -m pip install wheel twine==5.0.0 setuptools
twine upload /tmp/wheels/*.whl
build_wheels_linux:
needs: [core, test]
name: ${{ matrix.manylinux }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
manylinux: [manylinux2014] #, manylinux_2_28]
steps:
- uses: actions/checkout@v4
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
# see https://cibuildwheel.readthedocs.io/en/stable/changelog/
# for a list of versions
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_BEFORE_ALL: |
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
cd alsa-lib
./gitcompile
cd ..
echo "PWD"
ls -lh /project/alsa-lib/src/.libs
CIBW_ENVIRONMENT: >
SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH
SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs
LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR
SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
SHERPA_ONNX_ENABLE_ALSA=1
SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_BINARY=OFF -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF"
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
CIBW_BUILD_VERBOSITY: 3
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_x86_64
CIBW_REPAIR_WHEEL_COMMAND: >
auditwheel repair -w {dest_dir}
--exclude libonnxruntime.so
{wheel}
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}
path: ./wheelhouse/*.whl
- name: Show wheels
shell: bash
run: |
ls -lh wheelhouse/*.whl
unzip -l wheelhouse/*.whl
echo "---"
mkdir t
cp wheelhouse/*.whl ./t
cd ./t
unzip ./*.whl
ls -lh
echo "---"
readelf -d sherpa_onnx/lib/*.so
- name: Publish to huggingface
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
... ...
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,14 +20,246 @@ concurrency:
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-arm64
- 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 \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_OSX_ARCHITECTURES='arm64' \
-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_11_0_arm64
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_11_0_arm64
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-arm64
path: ./*.whl
test:
name: test
needs: [core]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from macos arm64
uses: actions/download-artifact@v4
with:
name: wheels-core-macos-arm64
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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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: |
opts='--break-system-packages'
python3 -m pip install $opts --upgrade pip
python3 -m pip install $opts wheel twine==5.0.0 setuptools
twine upload /tmp/wheels/*.whl
build_wheels_macos_arm64:
needs: [core, test]
name: ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
os: [macos-latest]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
steps:
- uses: actions/checkout@v4
... ... @@ -33,10 +271,12 @@ jobs:
git diff .
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='arm64'"
CIBW_ENVIRONMENT: >
SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='arm64' -DSHERPA_ONNX_ENABLE_BINARY=OFF -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF"
CIBW_ARCHS: "arm64"
CIBW_BUILD_VERBOSITY: 3
... ... @@ -47,6 +287,7 @@ jobs:
shell: bash
run: |
ls -lh ./wheelhouse/
unzip -l ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
... ... @@ -95,10 +336,6 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
opts='--break-system-packages'
v=${{ matrix.python-version }}
if [[ $v == cp38 || $v == cp39 ]]; then
opts=''
fi
python3 -m pip install $opts --upgrade pip
python3 -m pip install $opts wheel twine==5.0.0 setuptools
... ...
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,14 +20,247 @@ concurrency:
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-universal2
- 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 \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_OSX_ARCHITECTURES='arm64;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_universal2
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_universal2
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-universal
path: ./*.whl
test:
name: test ${{ matrix.os }}
needs: [core]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, macos-13]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from macos universal
uses: actions/download-artifact@v4
with:
name: wheels-core-macos-universal
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
if: matrix.os == 'macos-latest'
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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
- name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
if: ${{ matrix.os == 'macos-latest' && (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
shell: bash
run: |
opts='--break-system-packages'
python3 -m pip install $opts --upgrade pip
python3 -m pip install $opts wheel twine==5.0.0 setuptools
twine upload /tmp/wheels/*.whl
build_wheels_macos_universal2:
needs: [core, test]
name: ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
os: [macos-latest]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
steps:
- uses: actions/checkout@v4
... ... @@ -32,11 +271,17 @@ jobs:
./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@v2.21.3
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64'"
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET=10.15
SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='arm64;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: "universal2"
CIBW_BUILD_VERBOSITY: 3
... ... @@ -47,6 +292,7 @@ jobs:
shell: bash
run: |
ls -lh ./wheelhouse/
unzip -l ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
... ... @@ -95,10 +341,6 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
opts='--break-system-packages'
v=${{ matrix.python-version }}
if [[ $v == cp38 || $v == cp39 ]]; then
opts=''
fi
python3 -m pip install $opts --upgrade pip
python3 -m pip install $opts wheel twine==5.0.0 setuptools
... ...
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,44 +20,266 @@ concurrency:
cancel-in-progress: true
jobs:
build_wheels_macos_x64:
name: ${{ matrix.python-version }}
core:
runs-on: ${{ matrix.os }}
name: core
strategy:
fail-fast: false
matrix:
os: [macos-13]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
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"
# see https://cibuildwheel.readthedocs.io/en/stable/changelog/
# for a list of versions
- name: Build wheels
if: matrix.python-version == 'cp37'
uses: pypa/cibuildwheel@v2.11.4
- 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-13]
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:
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='x86_64'"
CIBW_ARCHS: "x86_64"
CIBW_BUILD_VERBOSITY: 3
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"
# Don't repair macOS wheels
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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 --upgrade pip
python3 -m pip install wheel twine==5.0.0 setuptools
twine upload /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
if: matrix.python-version != 'cp37'
uses: pypa/cibuildwheel@v2.21.3
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='x86_64'"
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
... ... @@ -62,10 +290,11 @@ jobs:
shell: bash
run: |
ls -lh ./wheelhouse/
unzip -l ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}
name: wheel-macos-x64-${{ matrix.python-version }}
path: ./wheelhouse/*.whl
- name: Publish to huggingface
... ... @@ -110,16 +339,8 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
opts='--break-system-packages'
v=${{ matrix.python-version }}
if [[ $v == cp37 || $v == cp38 || $v == cp39 ]]; then
opts=''
fi
python3 -m pip install $opts --upgrade pip
if [[ ${{ matrix.python-version }} == "cp37" ]]; then
python3 -m pip install $opts wheel twine setuptools
else
python3 -m pip install $opts wheel twine==5.0.0 setuptools
fi
python3 -m pip install $opts wheel twine==5.0.0 setuptools
twine upload ./wheelhouse/*.whl
... ...
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,14 +20,251 @@ concurrency:
cancel-in-progress: true
jobs:
core:
name: core
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install wheel twine==5.0.0 setuptools
- name: Install sccache
run: choco install sccache -y
- name: Cache sccache
uses: actions/cache@v3
with:
path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache
key: ${{ matrix.os }}-sccache-core-win32
restore-keys: |
${{ matrix.os }}-sccache-core-win32
- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
cmake \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-A Win32 \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for windows
shell: bash
run: |
cd build
cmake --build . --config Release -- -m:2
cmake --build . --config Release --target install -- -m:2
ls -lh ./bin/Release/sherpa-onnx.exe
- name: Show sccache stats
run: sccache --show-stats
- name: Show
shell: bash
run: |
echo "---bin---"
ls -lh build/install/bin
echo "---lib---"
ls -lh build/install/lib
echo "---include---"
ls -lh build/install/include
- name: Copy files
shell: bash
run: |
cd build
echo 'sherpa-onnx-core'
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
cp -v ./install/lib/onnxruntime.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
cp -v ./install/lib/sherpa-onnx-*.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
# keep the *.lib file so users can write code to link with our dll
cp -v ./install/lib/sherpa-onnx-*.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 ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
pushd ../scripts/wheel/sherpa-onnx-core
python3 setup.py bdist_wheel --plat-name=win32
ls -lh dist
popd
echo 'sherpa-onnx-bin'
mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
pushd ../scripts/wheel/sherpa-onnx-bin
python3 setup.py bdist_wheel --plat-name=win32
ls -lh dist
popd
- name: Collect wheels
shell: bash
run: |
mkdir wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheels-core-win-x86
path: ./wheelhouse/*.whl
- name: Show wheels
shell: bash
run: |
ls -lh ./scripts/wheel/sherpa-onnx-core/dist
ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
echo "---"
unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
test:
name: test
needs: [core]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from Windows x86
uses: actions/download-artifact@v4
with:
name: wheels-core-win-x86
path: /tmp/wheels
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
architecture: x86
- name: Show
shell: bash
run: |
ls -lh /d/tmp/wheels
- name: Install
shell: bash
run: |
python3 -m pip install /d/tmp/wheels/*.whl
- name: Show version
shell: bash
run: |
sherpa-onnx-version
which sherpa-onnx-version
- name: Show help
shell: bash
run: |
sherpa-onnx --help
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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
cd huggingface
git fetch
git pull
git merge -m "merge remote" --ff origin main
mkdir -p $d
cp -v /d/tmp/wheels/*.whl $d/
git status
git add .
git commit -m "add more wheels"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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 --upgrade pip
python3 -m pip install wheel twine==5.0.0 setuptools
twine upload /d/tmp/wheels/*.whl
build_wheels_win32:
needs: [core, test]
name: ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
python-version: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
steps:
- uses: actions/checkout@v4
... ... @@ -34,19 +277,23 @@ jobs:
# see https://cibuildwheel.readthedocs.io/en/stable/changelog/
# for a list of versions
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
- name: Build wheels (cibuildwheel)
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-A Win32"
CIBW_BUILD: "${{ matrix.python-version}}-* "
CIBW_SKIP: "*-win_amd64"
CIBW_BUILD_VERBOSITY: 3
CIBW_ENVIRONMENT: >
SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
SHERPA_ONNX_CMAKE_ARGS="-A Win32 -DSHERPA_ONNX_ENABLE_BINARY=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF"
- name: Display wheels
shell: bash
run: |
ls -lh ./wheelhouse/
unzip -l ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}
... ...
... ... @@ -5,6 +5,12 @@ on:
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
... ... @@ -14,13 +20,252 @@ concurrency:
cancel-in-progress: true
jobs:
core:
name: core
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install wheel twine==5.0.0 setuptools
- name: Install sccache
run: choco install sccache -y
- name: Cache sccache
uses: actions/cache@v3
with:
path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache
key: ${{ matrix.os }}-sccache-core
restore-keys: |
${{ matrix.os }}-sccache-core-
- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
cmake \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-A x64 \
-D SHERPA_ONNX_ENABLE_TTS=ON \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for windows
shell: bash
run: |
cd build
cmake --build . --config Release -- -m:2
cmake --build . --config Release --target install -- -m:2
ls -lh ./bin/Release/sherpa-onnx.exe
- name: Show sccache stats
run: sccache --show-stats
- name: Show
shell: bash
run: |
echo "---bin---"
ls -lh build/install/bin
echo "---lib---"
ls -lh build/install/lib
echo "---include---"
ls -lh build/install/include
- name: Copy files
shell: bash
run: |
cd build
echo 'sherpa-onnx-core'
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
cp -v ./install/lib/onnxruntime.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
cp -v ./install/lib/sherpa-onnx-*.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
# keep the *.lib file so users can write code to link with our dll
cp -v ./install/lib/sherpa-onnx-*.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 ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
pushd ../scripts/wheel/sherpa-onnx-core
python3 setup.py bdist_wheel --plat-name=win_amd64
ls -lh dist
popd
echo 'sherpa-onnx-bin'
mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
pushd ../scripts/wheel/sherpa-onnx-bin
python3 setup.py bdist_wheel --plat-name=win_amd64
ls -lh dist
popd
- name: Collect wheels
shell: bash
run: |
mkdir wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheels-core-win-x64
path: ./wheelhouse/*.whl
- name: Show wheels
shell: bash
run: |
ls -lh ./scripts/wheel/sherpa-onnx-core/dist
ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
echo "---"
unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
test:
name: test
needs: [core]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from Windows x64
uses: actions/download-artifact@v4
with:
name: wheels-core-win-x64
path: /tmp/wheels
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Show
shell: bash
run: |
ls -lh /d/tmp/wheels
- name: Install
shell: bash
run: |
python3 -m pip install /d/tmp/wheels/*.whl
- name: Show version
shell: bash
run: |
sherpa-onnx-version
which sherpa-onnx-version
- name: Show help
shell: bash
run: |
sherpa-onnx --help
echo "---"
sherpa-onnx-offline --help
echo "---"
sherpa-onnx-vad --help
which sherpa-onnx-vad
- 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://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
cd huggingface
git fetch
git pull
git merge -m "merge remote" --ff origin main
mkdir -p $d
cp -v /d/tmp/wheels/*.whl $d/
git status
git add .
git commit -m "add more wheels"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/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 --upgrade pip
python3 -m pip install wheel twine==5.0.0 setuptools
twine upload /d/tmp/wheels/*.whl
build_wheels_win64:
needs: [core, test]
name: ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022]
os: [windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
... ... @@ -37,10 +282,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
- name: Build wheels (cmd)
shell: bash
run: |
pip install setuptools wheel
python3 -m pip install setuptools wheel twine
export SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_BINARY=OFF -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_C_API=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF"
python3 setup.py bdist_wheel
... ... @@ -52,6 +301,7 @@ jobs:
shell: bash
run: |
ls -lh ./wheelhouse/
unzip -l ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
... ...
... ... @@ -160,6 +160,10 @@ jobs:
vits-piper-de_DE-miro-high
vits-piper-fr_FR-miro-high
vits-piper-en_US-miro-high
vits-piper-pl_PL-jarvis_wg_glos-medium
vits-piper-pl_PL-justyna_wg_glos-medium
vits-piper-pl_PL-meski_wg_glos-medium
vits-piper-pl_PL-zenski_wg_glos-medium
)
for d in ${dirs[@]}; do
src=scripts/piper/release/$d
... ...
... ... @@ -157,7 +157,7 @@ jobs:
mkdir t
cd t
unzip ../*.whl
readelf -d _sherpa_onnx*.so
readelf -d sherpa_onnx/lib/_sherpa_onnx*.so
echo "----"
... ... @@ -170,7 +170,7 @@ jobs:
mkdir t
cd t
unzip ../*.whl
readelf -d _sherpa_onnx*.so
readelf -d sherpa_onnx/lib/_sherpa_onnx*.so
echo "----"
... ...
... ... @@ -39,6 +39,19 @@ jobs:
- os: ubuntu-latest
python-version: "3.13"
- os: ubuntu-24.04-arm
python-version: "3.8"
- os: ubuntu-24.04-arm
python-version: "3.9"
- os: ubuntu-24.04-arm
python-version: "3.10"
- os: ubuntu-24.04-arm
python-version: "3.11"
- os: ubuntu-24.04-arm
python-version: "3.12"
- os: ubuntu-24.04-arm
python-version: "3.13"
- os: macos-13
python-version: "3.8"
... ... @@ -49,8 +62,10 @@ jobs:
- os: macos-13
python-version: "3.11"
- os: macos-14
- os: macos-latest
python-version: "3.12"
- os: macos-latest
python-version: "3.13"
- os: windows-2022
python-version: "3.7"
... ... @@ -65,6 +80,8 @@ jobs:
python-version: "3.11"
- os: windows-2022
python-version: "3.12"
- os: windows-latest
python-version: "3.13"
steps:
- uses: actions/checkout@v4
... ... @@ -120,6 +137,10 @@ jobs:
cd t
unzip ../*.whl
ls -lh sherpa_onnx/lib
file sherpa_onnx/lib/*
- name: Install wheel
shell: bash
run: |
... ... @@ -128,14 +149,5 @@ jobs:
- name: Test
shell: bash
run: |
# For windows
export PATH=/c/hostedtoolcache/windows/Python/3.7.9/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.11.9/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.12.10/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.13.6/x64/bin:$PATH
which sherpa-onnx
sherpa-onnx --help
... ...
... ... @@ -31,18 +31,29 @@ jobs:
# See https://github.com/actions/runner-images
include:
- os: ubuntu-22.04
python-version: "3.7"
- os: ubuntu-22.04
python-version: "3.8"
- os: ubuntu-22.04
python-version: "3.9"
- os: ubuntu-22.04
python-version: "3.10"
- os: ubuntu-22.04
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-22.04
- os: ubuntu-24.04
python-version: "3.12"
- os: ubuntu-22.04
- os: ubuntu-latest
python-version: "3.13"
- os: ubuntu-24.04-arm
python-version: "3.8"
- os: ubuntu-24.04-arm
python-version: "3.9"
- os: ubuntu-24.04-arm
python-version: "3.10"
- os: ubuntu-24.04-arm
python-version: "3.11"
- os: ubuntu-24.04-arm
python-version: "3.12"
- os: ubuntu-24.04-arm
python-version: "3.13"
- os: macos-13
... ... @@ -61,8 +72,6 @@ jobs:
python-version: "3.13"
- os: windows-2022
python-version: "3.7"
- os: windows-2022
python-version: "3.8"
- os: windows-2022
python-version: "3.9"
... ... @@ -95,29 +104,12 @@ jobs:
- name: Install sherpa-onnx
shell: bash
run: |
pip install --verbose sherpa-onnx
# python3 -m pip install --verbose .
pip install --verbose -U sherpa-onnx sherpa-onnx-core sherpa-onnx-bin
- name: Test sherpa-onnx
- name: Test sherpa-onnx-bin
shell: bash
run: |
python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)"
python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)"
p=$(python3 -c "from pathlib import Path; import sys; print(Path(sys.executable).parent)")
echo $p
ls -lh $p
# ls -lh $p/bin
# export PATH=$p/bin:$PATH
# For windows
export PATH=/c/hostedtoolcache/windows/Python/3.7.9/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.11.9/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.12.10/x64/bin:$PATH
export PATH=/c/hostedtoolcache/windows/Python/3.13.6/x64/bin:$PATH
sherpa-onnx-version
sherpa-onnx --help
sherpa-onnx-keyword-spotter --help
... ... @@ -131,3 +123,23 @@ jobs:
sherpa-onnx-online-websocket-server --help
sherpa-onnx-online-websocket-client --help
- name: Test sherpa-onnx-core
shell: bash
run: |
python3 -m sherpa_onnx --cflags
python3 -m sherpa_onnx --c-api-libs
python3 -m sherpa_onnx --c-api-libs-only-L
python3 -m sherpa_onnx --c-api-libs-only-l
python3 -m sherpa_onnx --cxx-api-libs
python3 -m sherpa_onnx --cxx-api-libs-only-L
python3 -m sherpa_onnx --cxx-api-libs-only-l
- name: Test sherpa-onnx
shell: bash
run: |
python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)"
python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)"
python3 -c "import sherpa_onnx; print(sherpa_onnx.OnlineRecognizer)"
python3 -c "import sherpa_onnx; print(sherpa_onnx.OfflineRecognizer)"
... ...
... ... @@ -146,3 +146,4 @@ dict
*.npz
voices.bin
kitten-nano-en-v0_1-fp16
*.egg-info
... ...
... ... @@ -13,6 +13,11 @@ import setuptools
from setuptools.command.build_ext import build_ext
def need_split_package():
ans = os.environ.get("SHERPA_ONNX_SPLIT_PYTHON_PACKAGE", None)
return ans is not None
def is_for_pypi():
ans = os.environ.get("SHERPA_ONNX_IS_FOR_PYPI", None)
return ans is not None
... ... @@ -138,19 +143,24 @@ class BuildExtension(build_ext):
if cmake_args == "":
cmake_args = "-DCMAKE_BUILD_TYPE=Release"
extra_cmake_args = f" -DCMAKE_INSTALL_PREFIX={install_dir} "
extra_cmake_args = ""
if not need_split_package():
extra_cmake_args += f" -DCMAKE_INSTALL_PREFIX={install_dir} "
extra_cmake_args += " -DBUILD_SHARED_LIBS=ON "
extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_EXE=OFF "
extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_TESTS=OFF "
extra_cmake_args += " -DBUILD_ESPEAK_NG_EXE=OFF "
extra_cmake_args += " -DBUILD_ESPEAK_NG_TESTS=OFF "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_C_API=ON "
if not need_split_package():
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_C_API=ON "
extra_cmake_args += " -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PYTHON=ON "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PORTAUDIO=ON "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_WEBSOCKET=ON "
if not need_split_package():
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_WEBSOCKET=ON "
if "PYTHON_EXECUTABLE" not in cmake_args:
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
... ... @@ -161,10 +171,17 @@ class BuildExtension(build_ext):
cmake_args = extra_cmake_args + cmake_args
if is_windows():
build_cmd = f"""
cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
cmake --build {self.build_temp} --target install --config Release -- -m:2
"""
if not need_split_package():
build_cmd = f"""
cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
cmake --build {self.build_temp} --target install --config Release -- -m:2
"""
else:
build_cmd = f"""
cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
cmake --build {self.build_temp} --target _sherpa_onnx --config Release -- -m:2
"""
print(f"build command is:\n{build_cmd}")
ret = os.system(
f"cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}"
... ... @@ -172,9 +189,14 @@ class BuildExtension(build_ext):
if ret != 0:
raise Exception("Failed to configure sherpa")
ret = os.system(
f"cmake --build {self.build_temp} --target install --config Release -- -m:2" # noqa
)
if not need_split_package():
ret = os.system(
f"cmake --build {self.build_temp} --target install --config Release -- -m:2" # noqa
)
else:
ret = os.system(
f"cmake --build {self.build_temp} --target _sherpa_onnx --config Release -- -m:2" # noqa
)
if ret != 0:
raise Exception("Failed to build and install sherpa")
else:
... ... @@ -185,19 +207,35 @@ class BuildExtension(build_ext):
make_args = "-j4"
if "-G Ninja" in cmake_args:
build_cmd = f"""
cd {self.build_temp}
cmake {cmake_args} {sherpa_onnx_dir}
ninja {make_args} install
"""
if not need_split_package():
build_cmd = f"""
cd {self.build_temp}
cmake {cmake_args} {sherpa_onnx_dir}
ninja {make_args} install
"""
else:
build_cmd = f"""
cd {self.build_temp}
cmake {cmake_args} {sherpa_onnx_dir}
ninja {make_args} _sherpa_onnx
"""
else:
build_cmd = f"""
cd {self.build_temp}
if not need_split_package():
build_cmd = f"""
cd {self.build_temp}
cmake {cmake_args} {sherpa_onnx_dir}
cmake {cmake_args} {sherpa_onnx_dir}
make {make_args} install/strip
"""
make {make_args} install/strip
"""
else:
build_cmd = f"""
cd {self.build_temp}
cmake {cmake_args} {sherpa_onnx_dir}
make {make_args} _sherpa_onnx
"""
print(f"build command is:\n{build_cmd}")
ret = os.system(build_cmd)
... ... @@ -208,6 +246,25 @@ class BuildExtension(build_ext):
"\nClick:\n\thttps://github.com/k2-fsa/sherpa-onnx/issues/new\n" # noqa
)
if need_split_package():
dst = os.path.join(f"{self.build_lib}", "sherpa_onnx", "lib")
os.system(f"mkdir {dst}")
os.system(f"dir {dst}")
import glob
ext = "pyd" if sys.platform.startswith("win") else "so"
pattern = os.path.join(self.build_temp, "**", f"_sherpa_onnx.*.{ext}")
matches = glob.glob(pattern, recursive=True)
print("matches", list(matches))
for f in matches:
print(f, os.path.join(f"{self.build_lib}", "sherpa_onnx", "lib"))
shutil.copy(f"{f}", dst)
os.system(f"dir {dst}")
return
suffix = ".exe" if is_windows() else ""
# Remember to also change setup.py
... ... @@ -236,6 +293,3 @@ class BuildExtension(build_ext):
if is_macos():
os.remove(f"{install_dir}/lib/libonnxruntime.dylib")
if is_windows():
shutil.rmtree(f"{install_dir}/lib")
... ...
... ... @@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
if(SHERPA_ONNX_ENABLE_PYTHON)
install(FILES ${onnxruntime_lib_files} DESTINATION ..)
else()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
endif()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
... ...
... ... @@ -132,10 +132,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
if(SHERPA_ONNX_ENABLE_PYTHON)
install(FILES ${onnxruntime_lib_files} DESTINATION ..)
else()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
endif()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
... ...
... ... @@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
if(SHERPA_ONNX_ENABLE_PYTHON)
install(FILES ${onnxruntime_lib_files} DESTINATION ..)
else()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
endif()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
... ...
... ... @@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
if(SHERPA_ONNX_ENABLE_PYTHON)
install(FILES ${onnxruntime_lib_files} DESTINATION ..)
else()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
endif()
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
... ...
function(download_pybind11)
include(FetchContent)
set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz")
set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-2.12.0.tar.gz")
set(pybind11_HASH "SHA256=bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7")
set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v3.0.0.tar.gz")
set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-3.0.0.tar.gz")
set(pybind11_HASH "SHA256=453b1a3e2b266c3ae9da872411cadb6d693ac18063bd73226d96cfb7015a200c")
# If you don't have access to the Internet,
# please pre-download pybind11
set(possible_file_locations
$ENV{HOME}/Downloads/pybind11-2.12.0.tar.gz
${CMAKE_SOURCE_DIR}/pybind11-2.12.0.tar.gz
${CMAKE_BINARY_DIR}/pybind11-2.12.0.tar.gz
/tmp/pybind11-2.12.0.tar.gz
/star-fj/fangjun/download/github/pybind11-2.12.0.tar.gz
$ENV{HOME}/Downloads/pybind11-3.0.0.tar.gz
${CMAKE_SOURCE_DIR}/pybind11-3.0.0.tar.gz
${CMAKE_BINARY_DIR}/pybind11-3.0.0.tar.gz
/tmp/pybind11-3.0.0.tar.gz
/star-fj/fangjun/download/github/pybind11-3.0.0.tar.gz
)
foreach(f IN LISTS possible_file_locations)
... ...
... ... @@ -7,6 +7,7 @@ new_version_code=20250817
old_version="1\.12\.8"
new_version="1\.12\.9"
replace_str="s/$old_version/$new_version/g"
sed -i.bak "$replace_str" ./sherpa-onnx/csrc/version.cc
... ... @@ -22,6 +23,10 @@ find android -name "build.gradle.kts" -type f -exec sed -i.bak "s/versionCode =
sed -i.bak "s/ static const char \*sha1.*/ static const char \*sha1 = \"$sha1\";/g" ./sherpa-onnx/csrc/version.cc
sed -i.bak "s/ static const char \*date.*/ static const char \*date = \"$date\";/g" ./sherpa-onnx/csrc/version.cc
find scripts/wheel -name "setup.py" -type f -exec sed -i.bak "$replace_str" {} \;
sed -i.bak "$replace_str" ./setup.py
sed -i.bak "$replace_str" ./build-ios-shared.sh
sed -i.bak "$replace_str" ./pom.xml
sed -i.bak "$replace_str" ./jitpack.yml
... ...
... ... @@ -24,13 +24,13 @@ git status
git diff
HF_MIRROR=hf.co
linux_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
linux_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
linux_wheel=$src_dir/$linux_wheel_filename
macos_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_universal2.whl
macos_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_universal2.whl
macos_wheel=$src_dir/$macos_wheel_filename
windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
windows_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
function process_linux() {
... ...
... ... @@ -26,19 +26,19 @@ pushd $src_dir
mkdir -p linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64
linux_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
linux_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
linux_x64_wheel=$src_dir/$linux_x64_wheel_filename
linux_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
linux_arm64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_aarch64.whl
linux_arm64_wheel=$src_dir/$linux_arm64_wheel_filename
macos_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
macos_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_x86_64.whl
macos_x64_wheel=$src_dir/$macos_x64_wheel_filename
macos_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
macos_arm64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_11_0_arm64.whl
macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename
windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
windows_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
windows_x86_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86.tar.bz2
... ...
... ... @@ -28,8 +28,8 @@ function linux() {
dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
unzip sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
unzip sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
cp -v sherpa_onnx/lib/*.so* $dst
... ... @@ -40,8 +40,8 @@ function linux() {
dst=$(realpath sherpa-onnx-go-linux/lib/aarch64-unknown-linux-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_aarch64.whl
unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_aarch64.whl
cp -v sherpa_onnx/lib/*.so* $dst
... ... @@ -85,8 +85,8 @@ function osx() {
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_x86_64.whl
unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_x86_64.whl
cp -v sherpa_onnx/lib/*.dylib $dst/
... ... @@ -103,8 +103,8 @@ function osx() {
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_11_0_arm64.whl
unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_11_0_arm64.whl
cp -v sherpa_onnx/lib/*.dylib $dst/
... ... @@ -138,8 +138,8 @@ function windows() {
dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
... ... @@ -150,8 +150,8 @@ function windows() {
dst=$(realpath sherpa-onnx-go-windows/lib/i686-pc-windows-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win32.whl
unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win32.whl
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
... ...
# Introduction
This folder is for developers only.
## sherpa-onnx-core
It contains the scripts for building the package sherpa-onnx-core.
```
python3 setup.py bdist_wheel --plat-name=macosx_10_15_x86_64
python3 setup.py bdist_wheel --plat-name=macosx_11_0_arm64
python3 setup.py bdist_wheel --plat-name=macosx_11_0_universal2
python3 setup.py bdist_wheel --plat-name=macosx_10_15_universal2
python3 setup.py bdist_wheel --plat-name=win_amd64
python3 setup.py bdist_wheel --plat-name=win32
python3 setup.py bdist_wheel --plat-name=manylinux2014_x86_64
python3 setup.py bdist_wheel --plat-name=manylinux2014_aarch64
python3 setup.py bdist_wheel --plat-name=linux_armv7l
```
## sherpa-onnx-bin
... ...
... ... @@ -40,23 +40,38 @@ def process(out_dir: Path, whl: Path):
py_version = "3.10"
elif "cp311" in str(whl):
py_version = "3.11"
else:
elif "cp312" in str(whl):
py_version = "3.12"
elif "cp313" in str(whl):
py_version = "3.13"
elif "py3-none" in str(whl):
py_version = None
else:
assert False, f"Unknow python version in {whl}"
if py_version:
rpath_list = [
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib",
f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib",
#
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib64",
f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib64",
#
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx.libs",
]
else:
rpath_list = []
for p in ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]:
rpath_list.extend(
[
f"$ORIGIN/../lib/python{p}/site-packages/sherpa_onnx/lib",
f"$ORIGIN/../lib/python{p}/dist-packages/sherpa_onnx/lib",
]
)
rpath_list = [
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib",
f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib",
#
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib64",
f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib64",
#
f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx.libs",
]
rpaths = ":".join(rpath_list)
for filename in glob.glob(
f"{tmp_dir}/sherpa_onnx-*data/data/bin/*", recursive=True
):
for filename in glob.glob(f"{tmp_dir}/sherpa_onnx*data/data/bin/*", recursive=True):
print(filename)
existing_rpath = (
subprocess.check_output(["patchelf", "--print-rpath", filename])
... ...
import glob
import platform
from setuptools import setup
def is_windows():
return platform.system() == "Windows"
bin_files = glob.glob("bin/*")
print("bin_files", bin_files)
setup(
name="sherpa-onnx-bin",
version="1.12.9",
description="Binary executables for sherpa-onnx",
author="The sherpa-onnx development team",
url="https://github.com/k2-fsa/sherpa-onnx",
author_email="dpovey@gmail.com",
zip_safe=False,
license="Apache 2.0",
packages=[],
data_files=[("Scripts", bin_files) if is_windows() else ("bin", bin_files)],
install_requires=[
"sherpa-onnx-core==1.12.9",
],
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
)
... ...
recursive-include sherpa_onnx/lib *
recursive-include sherpa_onnx/include *
... ...
import platform
from setuptools import setup
def is_windows():
return platform.system() == "Windows"
def get_binaries():
if not is_windows():
return None
libs = [
"onnxruntime.dll",
"sherpa-onnx-c-api.dll",
"sherpa-onnx-cxx-api.dll",
"sherpa-onnx-c-api.lib",
"sherpa-onnx-cxx-api.lib",
]
prefix = "./sherpa_onnx/lib"
return [f"{prefix}/{lib}" for lib in libs]
setup(
name="sherpa-onnx-core",
version="1.12.9",
description="Core shared libraries for sherpa-onnx",
packages=["sherpa_onnx"],
include_package_data=True,
data_files=[("Scripts", get_binaries())] if get_binaries() else None,
author="The sherpa-onnx development team",
url="https://github.com/k2-fsa/sherpa-onnx",
author_email="dpovey@gmail.com",
zip_safe=False,
license="Apache-2.0",
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
)
... ...
import sys
from . import _info
def main():
args = sys.argv[1:]
if not args:
print(
"Usage: python3 -m sherpa_onnx [--cflags|--c-api-libs|--c-api-libs-only-L|--c-api-libs-only-l|--cxx-api-libs|--cxx-api-libs-only-L|--cxx-api-libs-only-l]"
)
sys.exit(1)
if "--cflags" in args:
print(f"-I{_info.get_include_dir()}")
elif "--c-api-libs" in args:
lib_flags = " ".join(f"-l{lib}" for lib in _info.get_c_api_libs())
print(f"-L{_info.get_libs_dir()} {lib_flags}")
elif "--c-api-libs-only-L" in args:
print(f"-L{_info.get_libs_dir()}")
elif "--c-api-libs-only-l" in args:
print(" ".join(f"-l{lib}" for lib in _info.get_c_api_libs()))
elif "--cxx-api-libs" in args:
lib_flags = " ".join(f"-l{lib}" for lib in _info.get_cxx_api_libs())
print(f"-L{_info.get_libs_dir()} {lib_flags}")
elif "--cxx-api-libs-only-L" in args:
print(f"-L{_info.get_libs_dir()}")
elif "--cxx-api-libs-only-l" in args:
print(" ".join(f"-l{lib}" for lib in _info.get_cxx_api_libs()))
else:
print("Unknown option:", args[0])
sys.exit(1)
if __name__ == "__main__":
main()
... ...
from pathlib import Path
from typing import List
_pkg_dir = Path(__file__).parent
libs_dir = _pkg_dir / "lib"
include_dir = _pkg_dir / "include"
# List of libraries (without "lib" prefix, without extension)
# Adjust to match your actual .so/.dll/.dylib files
onnxruntime_lib = ["onnxruntime"]
c_lib = ["sherpa-onnx-c-api"] + onnxruntime_lib
cxx_lib = ["sherpa-onnx-cxx-api"] + c_lib
def get_include_dir() -> str:
return str(include_dir)
def get_libs_dir() -> str:
return str(libs_dir)
def get_c_api_libs() -> List[str]:
return c_lib
def get_cxx_api_libs() -> List[str]:
return cxx_lib
... ...
... ... @@ -12,6 +12,7 @@ from cmake.cmake_extension import (
cmake_extension,
get_binaries,
is_windows,
need_split_package,
)
... ... @@ -45,8 +46,11 @@ with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "a") as f:
def get_binaries_to_install():
if need_split_package():
return None
cmake_args = os.environ.get("SHERPA_ONNX_CMAKE_ARGS", "")
if '-DSHERPA_ONNX_ENABLE_BINARY=OFF' in cmake_args:
if "-DSHERPA_ONNX_ENABLE_BINARY=OFF" in cmake_args:
return None
bin_dir = Path("build") / "sherpa_onnx" / "bin"
... ... @@ -65,7 +69,7 @@ def get_binaries_to_install():
setuptools.setup(
name=package_name,
python_requires=">=3.6",
python_requires=">=3.7",
version=get_package_version(),
author="The sherpa-onnx development team",
author_email="dpovey@gmail.com",
... ... @@ -73,7 +77,13 @@ setuptools.setup(
"sherpa_onnx": "sherpa-onnx/python/sherpa_onnx",
},
packages=["sherpa_onnx"],
data_files=[("bin", get_binaries_to_install())] if get_binaries_to_install() else None,
data_files=[
("Scripts", get_binaries_to_install())
if is_windows()
else ("bin", get_binaries_to_install())
]
if get_binaries_to_install()
else None,
url="https://github.com/k2-fsa/sherpa-onnx",
long_description=read_long_description(),
long_description_content_type="text/markdown",
... ... @@ -91,6 +101,7 @@ setuptools.setup(
],
},
license="Apache licensed, as found in the LICENSE file",
install_requires=["sherpa-onnx-core==1.12.9"] if need_split_package() else None,
)
with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "r") as f:
... ...
... ... @@ -390,6 +390,10 @@ if(SHERPA_ONNX_ENABLE_BINARY)
if(SHERPA_ONNX_ENABLE_PYTHON)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
endforeach()
endif()
endforeach()
endif()
... ... @@ -464,6 +468,12 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
foreach(exe IN LISTS exes)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
endforeach()
elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
foreach(exe IN LISTS exes)
foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
endforeach()
endforeach()
endif()
endif()
... ... @@ -557,6 +567,12 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
foreach(exe IN LISTS exes)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
endforeach()
elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
foreach(exe IN LISTS exes)
foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
endforeach()
endforeach()
endif()
endif()
... ... @@ -613,6 +629,12 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
endforeach()
endif()
endif()
... ...
... ... @@ -23,7 +23,7 @@
namespace sherpa_onnx {
class Hypothesis;
struct Hypothesis;
class LodrFst {
public:
... ...
... ... @@ -114,6 +114,4 @@ if(SHERPA_ONNX_HAS_ALSA)
endif()
endif()
install(TARGETS _sherpa_onnx
DESTINATION ../
)
install(TARGETS _sherpa_onnx DESTINATION lib)
... ...
... ... @@ -9,8 +9,6 @@
#include "sherpa-onnx/csrc/fast-clustering.h"
#define C_CONTIGUOUS py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_
namespace sherpa_onnx {
static void PybindFastClusteringConfig(py::module *m) {
... ... @@ -34,7 +32,7 @@ void PybindFastClustering(py::module *m) {
"__call__",
[](const PyClass &self,
py::array_t<float> features) -> std::vector<int32_t> {
if (!(C_CONTIGUOUS == (features.flags() & C_CONTIGUOUS))) {
if (!(features.flags() & py::array::c_style)) {
throw py::value_error(
"input features should be contiguous. Please use "
"np.ascontiguousarray(features)");
... ...
... ... @@ -80,7 +80,7 @@ void PybindOfflineSourceSeparation(py::module *m) {
"process",
[](const PyClass &self, int32_t sample_rate,
const py::array_t<float> &samples) {
if (!(C_CONTIGUOUS == (samples.flags() & C_CONTIGUOUS))) {
if (!(samples.flags() & py::array::c_style)) {
throw py::value_error(
"input samples should be contiguous. Please use "
"np.ascontiguousarray(samples)");
... ...
... ... @@ -5,6 +5,8 @@
#ifndef SHERPA_ONNX_PYTHON_CSRC_SHERPA_ONNX_H_
#define SHERPA_ONNX_PYTHON_CSRC_SHERPA_ONNX_H_
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include "pybind11/functional.h"
#include "pybind11/numpy.h"
#include "pybind11/pybind11.h"
... ...
from _sherpa_onnx import (
from sherpa_onnx.lib._sherpa_onnx import (
Alsa,
AudioEvent,
AudioTagging,
... ...
... ... @@ -3,7 +3,7 @@
from pathlib import Path
from typing import List, Optional
from _sherpa_onnx import (
from sherpa_onnx.lib._sherpa_onnx import (
FeatureExtractorConfig,
KeywordSpotterConfig,
OnlineModelConfig,
... ... @@ -12,7 +12,7 @@ from _sherpa_onnx import (
ProviderConfig,
)
from _sherpa_onnx import KeywordSpotter as _KeywordSpotter
from sherpa_onnx.lib._sherpa_onnx import KeywordSpotter as _KeywordSpotter
def _assert_file_exists(f: str):
... ...
... ... @@ -3,7 +3,7 @@
from pathlib import Path
from typing import List, Optional
from _sherpa_onnx import (
from sherpa_onnx.lib._sherpa_onnx import (
FeatureExtractorConfig,
HomophoneReplacerConfig,
OfflineCanaryModelConfig,
... ... @@ -16,8 +16,8 @@ from _sherpa_onnx import (
OfflineNemoEncDecCtcModelConfig,
OfflineParaformerModelConfig,
)
from _sherpa_onnx import OfflineRecognizer as _Recognizer
from _sherpa_onnx import (
from sherpa_onnx.lib._sherpa_onnx import OfflineRecognizer as _Recognizer
from sherpa_onnx.lib._sherpa_onnx import (
OfflineRecognizerConfig,
OfflineSenseVoiceModelConfig,
OfflineStream,
... ...
... ... @@ -2,7 +2,7 @@
from pathlib import Path
from typing import List, Optional
from _sherpa_onnx import (
from sherpa_onnx.lib._sherpa_onnx import (
CudaConfig,
EndpointConfig,
FeatureExtractorConfig,
... ... @@ -13,8 +13,8 @@ from _sherpa_onnx import (
OnlineNeMoCtcModelConfig,
OnlineParaformerModelConfig,
)
from _sherpa_onnx import OnlineRecognizer as _Recognizer
from _sherpa_onnx import (
from sherpa_onnx.lib._sherpa_onnx import OnlineRecognizer as _Recognizer
from sherpa_onnx.lib._sherpa_onnx import (
OnlineRecognizerConfig,
OnlineRecognizerResult,
OnlineStream,
... ...