Fangjun Kuang
Committed by GitHub

Split sherpa-onnx Python package (#2521)

正在显示 41 个修改的文件 包含 2261 行增加213 行删除
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,7 +20,277 @@ concurrency: @@ -14,7 +20,277 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
  23 + core:
  24 + name: core
  25 + runs-on: ${{ matrix.os }}
  26 + strategy:
  27 + fail-fast: false
  28 + matrix:
  29 + os: [ubuntu-24.04-arm]
  30 +
  31 + steps:
  32 + - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
  35 +
  36 + - name: Update version
  37 + shell: bash
  38 + run: |
  39 + ./new-release.sh
  40 + git diff .
  41 +
  42 + - name: Display PWD
  43 + shell: bash
  44 + run: |
  45 + echo "pwd: $PWD"
  46 + ls -lh
  47 + du -h -d1 .
  48 +
  49 + - name: Build sherpa-onnx
  50 + uses: addnab/docker-run-action@v3
  51 + with:
  52 + image: quay.io/pypa/manylinux2014_aarch64
  53 + options: |
  54 + --volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
  55 + shell: bash
  56 + run: |
  57 + uname -a
  58 + gcc --version
  59 + cmake --version
  60 + cat /etc/*release
  61 + id
  62 + pwd
  63 +
  64 + cd /home/runner/work/sherpa-onnx/sherpa-onnx
  65 +
  66 + find /opt -name "python*"
  67 +
  68 + echo "--------------------"
  69 + export PATH=/opt/_internal/cpython-3.10.18/bin:$PATH
  70 + which python3
  71 + python3 --version
  72 +
  73 + python3 -m venv my
  74 +
  75 + source ./my/bin/activate
  76 +
  77 + python3 -m pip install setuptools wheel twine
  78 +
  79 + git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
  80 + pushd alsa-lib
  81 + ./gitcompile
  82 + popd
  83 +
  84 + export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
  85 + export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
  86 +
  87 + mkdir build
  88 + pushd build
  89 +
  90 + cmake \
  91 + -D SHERPA_ONNX_ENABLE_TTS=ON \
  92 + -D CMAKE_BUILD_TYPE=Release \
  93 + -D BUILD_SHARED_LIBS=ON \
  94 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  95 + -D CMAKE_INSTALL_PREFIX=./install \
  96 + ..
  97 +
  98 + make -j2
  99 + make install
  100 +
  101 + ls -lh lib
  102 + ls -lh bin
  103 +
  104 + echo "----"
  105 + ls -lh install/lib
  106 +
  107 + rm -fv install/lib/libcargs.so
  108 +
  109 + echo "----"
  110 + ls -lh install/bin
  111 +
  112 + echo 'sherpa-onnx-core'
  113 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  114 + cp -v ./install/lib/lib*.so ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  115 +
  116 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  117 + cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  118 +
  119 + pushd ../scripts/wheel/sherpa-onnx-core
  120 + python3 setup.py bdist_wheel --plat-name=manylinux2014_aarch64
  121 +
  122 + ls -lh dist
  123 +
  124 + popd
  125 +
  126 + echo 'sherpa-onnx-bin'
  127 +
  128 + mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
  129 + cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
  130 +
  131 + pushd ../scripts/wheel/sherpa-onnx-bin
  132 + python3 setup.py bdist_wheel --plat-name=manylinux2014_aarch64
  133 +
  134 + ls -lh dist
  135 +
  136 + popd
  137 +
  138 + - name: Collect wheels
  139 + shell: bash
  140 + run: |
  141 + sudo chown -R $USER ./scripts/wheel
  142 + mkdir wheelhouse
  143 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
  144 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
  145 +
  146 + - uses: actions/upload-artifact@v4
  147 + with:
  148 + name: wheels-core-linux-aarch64
  149 + path: ./wheelhouse/*.whl
  150 +
  151 + - name: Show wheels
  152 + shell: bash
  153 + run: |
  154 + sudo chown -R $USER ./scripts/wheel
  155 + ls -lh ./scripts/wheel/sherpa-onnx-core/dist
  156 + ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
  157 +
  158 + unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
  159 + echo "---"
  160 + unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
  161 +
  162 + - name: Install patchelf
  163 + shell: bash
  164 + run: |
  165 + sudo apt-get update -q
  166 + sudo apt-get install -q -y patchelf
  167 + patchelf --help
  168 +
  169 + - name: Patch wheels
  170 + shell: bash
  171 + run: |
  172 + mkdir ./wheels
  173 + sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels
  174 +
  175 + ls -lh ./wheels/
  176 + rm -rf ./wheelhouse
  177 + mv ./wheels ./wheelhouse
  178 +
  179 + - uses: actions/upload-artifact@v4
  180 + with:
  181 + name: wheels-core-linux-aarch64-patched
  182 + path: ./wheelhouse/*.whl
  183 +
  184 + test:
  185 + name: test
  186 + needs: [core]
  187 + runs-on: ${{ matrix.os }}
  188 + strategy:
  189 + fail-fast: false
  190 + matrix:
  191 + os: [ubuntu-24.04-arm]
  192 +
  193 + steps:
  194 + - uses: actions/checkout@v4
  195 + with:
  196 + fetch-depth: 0
  197 +
  198 + - name: Retrieve artifact from Linux x64
  199 + uses: actions/download-artifact@v4
  200 + with:
  201 + name: wheels-core-linux-aarch64-patched
  202 + path: /tmp/wheels
  203 +
  204 + - name: Setup Python
  205 + uses: actions/setup-python@v5
  206 + with:
  207 + python-version: "3.10"
  208 +
  209 + - name: Show
  210 + shell: bash
  211 + run: |
  212 + ls -lh /tmp/wheels
  213 +
  214 + - name: Install
  215 + shell: bash
  216 + run: |
  217 + python3 -m pip install /tmp/wheels/*.whl
  218 +
  219 + - name: Show version
  220 + shell: bash
  221 + run: |
  222 + sherpa-onnx-version
  223 +
  224 + - name: Show help
  225 + shell: bash
  226 + run: |
  227 + sherpa-onnx --help
  228 +
  229 + echo "---"
  230 +
  231 + ls -lh $(which sherpa-onnx)
  232 + file $(which sherpa-onnx)
  233 + readelf -d $(which sherpa-onnx)
  234 +
  235 + ldd $(which sherpa-onnx)
  236 +
  237 + sherpa-onnx-offline --help
  238 +
  239 + echo "---"
  240 +
  241 + sherpa-onnx-vad --help
  242 +
  243 + - name: Publish to huggingface
  244 + env:
  245 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  246 + uses: nick-fields/retry@v3
  247 + with:
  248 + max_attempts: 20
  249 + timeout_seconds: 200
  250 + shell: bash
  251 + command: |
  252 + git config --global user.email "csukuangfj@gmail.com"
  253 + git config --global user.name "Fangjun Kuang"
  254 +
  255 + rm -rf huggingface
  256 + export GIT_LFS_SKIP_SMUDGE=1
  257 + export GIT_CLONE_PROTECTION_ACTIVE=false
  258 +
  259 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  260 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  261 +
  262 + d=cpu/$SHERPA_ONNX_VERSION
  263 +
  264 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  265 + cd huggingface
  266 + git fetch
  267 + git pull
  268 + git merge -m "merge remote" --ff origin main
  269 +
  270 + mkdir -p $d
  271 +
  272 + cp -v /tmp/wheels/*.whl $d/
  273 +
  274 + git status
  275 + git add .
  276 + git commit -m "add more wheels"
  277 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  278 +
  279 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  280 + if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  281 + env:
  282 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  283 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  284 + shell: bash
  285 + run: |
  286 + python3 -m pip install --upgrade pip
  287 + python3 -m pip install wheel twine==5.0.0 setuptools
  288 +
  289 + twine upload /tmp/wheels/*.whl
  290 +
  291 +
17 build_wheels_aarch64: 292 build_wheels_aarch64:
  293 + needs: [core, test]
18 name: ${{ matrix.manylinux }} ${{ matrix.python-version }} 294 name: ${{ matrix.manylinux }} ${{ matrix.python-version }}
19 runs-on: ${{ matrix.os }} 295 runs-on: ${{ matrix.os }}
20 strategy: 296 strategy:
@@ -22,8 +298,8 @@ jobs: @@ -22,8 +298,8 @@ jobs:
22 matrix: 298 matrix:
23 # see https://github.com/pypa/cibuildwheel/issues/2257 299 # see https://github.com/pypa/cibuildwheel/issues/2257
24 # we don't use qemu from now on 300 # we don't use qemu from now on
25 - os: [ubuntu-22.04-arm]  
26 - python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 301 + os: [ubuntu-24.04-arm]
  302 + python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
27 manylinux: [manylinux2014] #, manylinux_2_28] 303 manylinux: [manylinux2014] #, manylinux_2_28]
28 304
29 steps: 305 steps:
@@ -38,7 +314,7 @@ jobs: @@ -38,7 +314,7 @@ jobs:
38 # see https://cibuildwheel.readthedocs.io/en/stable/changelog/ 314 # see https://cibuildwheel.readthedocs.io/en/stable/changelog/
39 # for a list of versions 315 # for a list of versions
40 - name: Build wheels 316 - name: Build wheels
41 - uses: pypa/cibuildwheel@v2.21.3 317 + uses: pypa/cibuildwheel@v3.1.4
42 env: 318 env:
43 CIBW_BEFORE_ALL: | 319 CIBW_BEFORE_ALL: |
44 git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib 320 git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
@@ -48,7 +324,15 @@ jobs: @@ -48,7 +324,15 @@ jobs:
48 echo "PWD" 324 echo "PWD"
49 ls -lh /project/alsa-lib/src/.libs 325 ls -lh /project/alsa-lib/src/.libs
50 326
51 - 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 327 + CIBW_ENVIRONMENT: >
  328 + SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  329 + CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH
  330 + SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs
  331 + LD_LIBRARY_PATH=/project/build/bdist.linux-aarch64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR
  332 + SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
  333 + SHERPA_ONNX_ENABLE_ALSA=1
  334 + 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"
  335 +
52 CIBW_BUILD: "${{ matrix.python-version}}-* " 336 CIBW_BUILD: "${{ matrix.python-version}}-* "
53 CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686" 337 CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
54 CIBW_BUILD_VERBOSITY: 3 338 CIBW_BUILD_VERBOSITY: 3
@@ -57,28 +341,38 @@ jobs: @@ -57,28 +341,38 @@ jobs:
57 CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_aarch64 341 CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_aarch64
58 # From onnxruntime >= 1.17.0, it drops support for CentOS 7.0 and it supports only manylinux_2_28. 342 # From onnxruntime >= 1.17.0, it drops support for CentOS 7.0 and it supports only manylinux_2_28.
59 # manylinux_2_24 is no longer supported 343 # manylinux_2_24 is no longer supported
  344 + CIBW_REPAIR_WHEEL_COMMAND: >
  345 + auditwheel repair -w {dest_dir}
  346 + --exclude libonnxruntime.so
  347 + {wheel}
  348 +
  349 + - uses: actions/upload-artifact@v4
  350 + with:
  351 + name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}-linux-aarch64
  352 + path: ./wheelhouse/*.whl
60 353
61 - name: Display wheels 354 - name: Display wheels
62 shell: bash 355 shell: bash
63 run: | 356 run: |
64 ls -lh ./wheelhouse/ 357 ls -lh ./wheelhouse/
65 358
66 - - name: Install patchelf 359 + - name: Show wheels
67 shell: bash 360 shell: bash
68 run: | 361 run: |
69 - sudo apt-get update -q  
70 - sudo apt-get install -q -y patchelf  
71 - patchelf --help 362 + ls -lh wheelhouse/*.whl
72 363
73 - - name: Patch wheels  
74 - shell: bash  
75 - run: |  
76 - mkdir ./wheels  
77 - sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels 364 + unzip -l wheelhouse/*.whl
78 365
79 - ls -lh ./wheels/  
80 - rm -rf ./wheelhouse  
81 - mv ./wheels ./wheelhouse 366 + echo "---"
  367 +
  368 + mkdir t
  369 + cp wheelhouse/*.whl ./t
  370 + cd ./t
  371 + unzip ./*.whl
  372 + ls -lh
  373 + echo "---"
  374 +
  375 + readelf -d sherpa_onnx/lib/*.so
82 376
83 - name: Publish to huggingface 377 - name: Publish to huggingface
84 env: 378 env:
@@ -116,11 +410,6 @@ jobs: @@ -116,11 +410,6 @@ jobs:
116 git commit -m "add more wheels" 410 git commit -m "add more wheels"
117 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main 411 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
118 412
119 - - uses: actions/upload-artifact@v4  
120 - with:  
121 - name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}  
122 - path: ./wheelhouse/*.whl  
123 -  
124 - name: Publish wheels to PyPI 413 - name: Publish wheels to PyPI
125 env: 414 env:
126 TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 415 TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,19 +20,18 @@ concurrency: @@ -14,19 +20,18 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
17 - build_wheels_linux:  
18 - name: ${{ matrix.manylinux }} ${{ matrix.python-version }} 23 + core:
  24 + name: core
19 runs-on: ${{ matrix.os }} 25 runs-on: ${{ matrix.os }}
20 strategy: 26 strategy:
21 fail-fast: false 27 fail-fast: false
22 matrix: 28 matrix:
23 - os: [ubuntu-22.04]  
24 - python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]  
25 - manylinux: [manylinux2014] #, manylinux_2_28]  
26 - 29 + os: [ubuntu-latest]
27 30
28 steps: 31 steps:
29 - uses: actions/checkout@v4 32 - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
30 35
31 - name: Update version 36 - name: Update version
32 shell: bash 37 shell: bash
@@ -34,30 +39,127 @@ jobs: @@ -34,30 +39,127 @@ jobs:
34 ./new-release.sh 39 ./new-release.sh
35 git diff . 40 git diff .
36 41
37 - # see https://cibuildwheel.readthedocs.io/en/stable/changelog/  
38 - # for a list of versions  
39 - - name: Build wheels  
40 - uses: pypa/cibuildwheel@v2.21.3  
41 - env:  
42 - CIBW_BEFORE_ALL: | 42 + - name: Display PWD
  43 + shell: bash
  44 + run: |
  45 + echo "pwd: $PWD"
  46 + ls -lh
  47 + du -h -d1 .
  48 +
  49 + - name: Build sherpa-onnx
  50 + uses: addnab/docker-run-action@v3
  51 + with:
  52 + image: quay.io/pypa/manylinux2014_x86_64
  53 + options: |
  54 + --volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
  55 + shell: bash
  56 + run: |
  57 + uname -a
  58 + gcc --version
  59 + cmake --version
  60 + cat /etc/*release
  61 + id
  62 + pwd
  63 +
  64 + cd /home/runner/work/sherpa-onnx/sherpa-onnx
  65 +
  66 + find /opt -name "python*"
  67 +
  68 + echo "--------------------"
  69 + export PATH=/opt/_internal/cpython-3.10.18/bin:$PATH
  70 + which python3
  71 + python3 --version
  72 +
  73 + python3 -m venv my
  74 +
  75 + source ./my/bin/activate
  76 +
  77 + python3 -m pip install setuptools wheel twine
  78 +
43 git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib 79 git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
44 - cd alsa-lib 80 + pushd alsa-lib
45 ./gitcompile 81 ./gitcompile
46 - cd ..  
47 - echo "PWD"  
48 - ls -lh /project/alsa-lib/src/.libs 82 + popd
49 83
50 - 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 84 + export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
  85 + export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
51 86
52 - CIBW_BUILD: "${{ matrix.python-version}}-* "  
53 - CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"  
54 - CIBW_BUILD_VERBOSITY: 3  
55 - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_x86_64 87 + mkdir build
  88 + pushd build
  89 +
  90 + cmake \
  91 + -D SHERPA_ONNX_ENABLE_TTS=ON \
  92 + -D CMAKE_BUILD_TYPE=Release \
  93 + -D BUILD_SHARED_LIBS=ON \
  94 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  95 + -D CMAKE_INSTALL_PREFIX=./install \
  96 + ..
  97 +
  98 + make -j2
  99 + make install
  100 +
  101 + ls -lh lib
  102 + ls -lh bin
  103 +
  104 + echo "----"
  105 + ls -lh install/lib
  106 +
  107 + rm -fv install/lib/libcargs.so
  108 +
  109 + echo "----"
  110 + ls -lh install/bin
  111 +
  112 + echo 'sherpa-onnx-core'
  113 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  114 + cp -v ./install/lib/lib*.so ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  115 +
  116 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  117 + cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  118 +
  119 + pushd ../scripts/wheel/sherpa-onnx-core
  120 + python3 setup.py bdist_wheel --plat-name=manylinux2014_x86_64
  121 +
  122 + ls -lh dist
  123 + unzip -l dist/*.whl
  124 +
  125 + popd
  126 +
  127 + echo 'sherpa-onnx-bin'
  128 +
  129 + mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
  130 + cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
56 131
57 - - name: Display wheels 132 + pushd ../scripts/wheel/sherpa-onnx-bin
  133 + python3 setup.py bdist_wheel --plat-name=manylinux2014_x86_64
  134 +
  135 + ls -lh dist
  136 + unzip -l dist/*.whl
  137 +
  138 + popd
  139 +
  140 + - name: Collect wheels
58 shell: bash 141 shell: bash
59 run: | 142 run: |
60 - ls -lh ./wheelhouse/ 143 + sudo chown -R $USER ./scripts/wheel
  144 + mkdir wheelhouse
  145 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
  146 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
  147 +
  148 + - uses: actions/upload-artifact@v4
  149 + with:
  150 + name: wheels-core-linux-x64
  151 + path: ./wheelhouse/*.whl
  152 +
  153 + - name: Show wheels
  154 + shell: bash
  155 + run: |
  156 + sudo chown -R $USER ./scripts/wheel
  157 + ls -lh ./scripts/wheel/sherpa-onnx-core/dist
  158 + ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
  159 +
  160 + unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
  161 + echo "---"
  162 + unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
61 163
62 - name: Install patchelf 164 - name: Install patchelf
63 shell: bash 165 shell: bash
@@ -78,9 +180,189 @@ jobs: @@ -78,9 +180,189 @@ jobs:
78 180
79 - uses: actions/upload-artifact@v4 181 - uses: actions/upload-artifact@v4
80 with: 182 with:
  183 + name: wheels-core-linux-x64-patched
  184 + path: ./wheelhouse/*.whl
  185 +
  186 + test:
  187 + name: test
  188 + needs: [core]
  189 + runs-on: ${{ matrix.os }}
  190 + strategy:
  191 + fail-fast: false
  192 + matrix:
  193 + os: [ubuntu-latest]
  194 +
  195 + steps:
  196 + - uses: actions/checkout@v4
  197 + with:
  198 + fetch-depth: 0
  199 +
  200 + - name: Retrieve artifact from Linux x64
  201 + uses: actions/download-artifact@v4
  202 + with:
  203 + name: wheels-core-linux-x64-patched
  204 + path: /tmp/wheels
  205 +
  206 + - name: Setup Python
  207 + uses: actions/setup-python@v5
  208 + with:
  209 + python-version: "3.10"
  210 +
  211 + - name: Show
  212 + shell: bash
  213 + run: |
  214 + ls -lh /tmp/wheels
  215 +
  216 + - name: Install
  217 + shell: bash
  218 + run: |
  219 + python3 -m pip install /tmp/wheels/*.whl
  220 +
  221 + - name: Show version
  222 + shell: bash
  223 + run: |
  224 + sherpa-onnx-version
  225 +
  226 + - name: Show help
  227 + shell: bash
  228 + run: |
  229 + sherpa-onnx --help
  230 +
  231 + echo "---"
  232 +
  233 + ls -lh $(which sherpa-onnx)
  234 + file $(which sherpa-onnx)
  235 + readelf -d $(which sherpa-onnx)
  236 +
  237 + ldd $(which sherpa-onnx)
  238 +
  239 + sherpa-onnx-offline --help
  240 +
  241 + echo "---"
  242 +
  243 + sherpa-onnx-vad --help
  244 +
  245 + - name: Publish to huggingface
  246 + env:
  247 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  248 + uses: nick-fields/retry@v3
  249 + with:
  250 + max_attempts: 20
  251 + timeout_seconds: 200
  252 + shell: bash
  253 + command: |
  254 + git config --global user.email "csukuangfj@gmail.com"
  255 + git config --global user.name "Fangjun Kuang"
  256 +
  257 + rm -rf huggingface
  258 + export GIT_LFS_SKIP_SMUDGE=1
  259 + export GIT_CLONE_PROTECTION_ACTIVE=false
  260 +
  261 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  262 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  263 +
  264 + d=cpu/$SHERPA_ONNX_VERSION
  265 +
  266 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  267 + cd huggingface
  268 + git fetch
  269 + git pull
  270 + git merge -m "merge remote" --ff origin main
  271 +
  272 + mkdir -p $d
  273 +
  274 + cp -v /tmp/wheels/*.whl $d/
  275 +
  276 + git status
  277 + git add .
  278 + git commit -m "add more wheels"
  279 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  280 +
  281 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  282 + if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  283 + env:
  284 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  285 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  286 + shell: bash
  287 + run: |
  288 + python3 -m pip install --upgrade pip
  289 + python3 -m pip install wheel twine==5.0.0 setuptools
  290 +
  291 + twine upload /tmp/wheels/*.whl
  292 +
  293 + build_wheels_linux:
  294 + needs: [core, test]
  295 + name: ${{ matrix.manylinux }} ${{ matrix.python-version }}
  296 + runs-on: ${{ matrix.os }}
  297 + strategy:
  298 + fail-fast: false
  299 + matrix:
  300 + os: [ubuntu-latest]
  301 + python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
  302 + manylinux: [manylinux2014] #, manylinux_2_28]
  303 +
  304 + steps:
  305 + - uses: actions/checkout@v4
  306 +
  307 + - name: Update version
  308 + shell: bash
  309 + run: |
  310 + ./new-release.sh
  311 + git diff .
  312 +
  313 + # see https://cibuildwheel.readthedocs.io/en/stable/changelog/
  314 + # for a list of versions
  315 + - name: Build wheels
  316 + uses: pypa/cibuildwheel@v3.1.4
  317 + env:
  318 + CIBW_BEFORE_ALL: |
  319 + git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
  320 + cd alsa-lib
  321 + ./gitcompile
  322 + cd ..
  323 + echo "PWD"
  324 + ls -lh /project/alsa-lib/src/.libs
  325 +
  326 + CIBW_ENVIRONMENT: >
  327 + SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  328 + CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH
  329 + SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs
  330 + LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR
  331 + SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
  332 + SHERPA_ONNX_ENABLE_ALSA=1
  333 + 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"
  334 +
  335 + CIBW_BUILD: "${{ matrix.python-version}}-* "
  336 + CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
  337 + CIBW_BUILD_VERBOSITY: 3
  338 + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.manylinux }}_x86_64
  339 + CIBW_REPAIR_WHEEL_COMMAND: >
  340 + auditwheel repair -w {dest_dir}
  341 + --exclude libonnxruntime.so
  342 + {wheel}
  343 +
  344 + - uses: actions/upload-artifact@v4
  345 + with:
81 name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }} 346 name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}
82 path: ./wheelhouse/*.whl 347 path: ./wheelhouse/*.whl
83 348
  349 + - name: Show wheels
  350 + shell: bash
  351 + run: |
  352 + ls -lh wheelhouse/*.whl
  353 + unzip -l wheelhouse/*.whl
  354 +
  355 + echo "---"
  356 +
  357 + mkdir t
  358 + cp wheelhouse/*.whl ./t
  359 + cd ./t
  360 + unzip ./*.whl
  361 + ls -lh
  362 + echo "---"
  363 +
  364 + readelf -d sherpa_onnx/lib/*.so
  365 +
84 - name: Publish to huggingface 366 - name: Publish to huggingface
85 env: 367 env:
86 HF_TOKEN: ${{ secrets.HF_TOKEN }} 368 HF_TOKEN: ${{ secrets.HF_TOKEN }}
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,14 +20,246 @@ concurrency: @@ -14,14 +20,246 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
  23 + core:
  24 + runs-on: ${{ matrix.os }}
  25 + name: core
  26 + strategy:
  27 + fail-fast: false
  28 + matrix:
  29 + os: [macos-latest]
  30 +
  31 + steps:
  32 + - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
  35 +
  36 + - name: Update version
  37 + shell: bash
  38 + run: |
  39 + ./new-release.sh
  40 + git diff .
  41 + - name: Set up Python
  42 + uses: actions/setup-python@v5
  43 + with:
  44 + python-version: "3.10"
  45 +
  46 + - name: Install deps
  47 + shell: bash
  48 + run: |
  49 + python3 -m pip install setuptools wheel twine
  50 +
  51 + - name: ccache
  52 + uses: hendrikmuhs/ccache-action@v1.2
  53 + with:
  54 + key: macos-latest-sherpa-onnx-core-arm64
  55 +
  56 + - name: Configure CMake
  57 + shell: bash
  58 + run: |
  59 + export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  60 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  61 + cmake --version
  62 +
  63 + mkdir build
  64 + cd build
  65 +
  66 + cmake \
  67 + -DSHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON \
  68 + -D BUILD_SHARED_LIBS=ON \
  69 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  70 + -D CMAKE_BUILD_TYPE=Release \
  71 + -D CMAKE_OSX_ARCHITECTURES='arm64' \
  72 + -D CMAKE_INSTALL_PREFIX=./install \
  73 + ..
  74 +
  75 + - name: Build sherpa-onnx for macos
  76 + shell: bash
  77 + run: |
  78 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  79 +
  80 + cd build
  81 + make -j2
  82 + make install
  83 +
  84 + ls -lh lib
  85 + ls -lh bin
  86 +
  87 + file ./bin/sherpa-onnx
  88 +
  89 + rm -fv ./install/include/cargs.h
  90 + rm -fv ./install/lib/cargs.h
  91 + rm -fv ./install/lib/libcargs.dylib
  92 + rm -fv ./install/lib/libcargs.a
  93 + rm -rfv ./install/lib/pkgconfig
  94 +
  95 + - name: Copy files
  96 + shell: bash
  97 + run: |
  98 + echo 'sherpa-onnx-core'
  99 + mkdir -p scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  100 + cp -v ./build/install/lib/lib* ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  101 +
  102 + mkdir -p ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  103 + cp -v ./build/install/include/sherpa-onnx/c-api/*.h ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  104 +
  105 + echo 'sherpa-onnx-bin'
  106 +
  107 + mkdir -p ./scripts/wheel/sherpa-onnx-bin/bin
  108 + cp -v ./build/install/bin/sherpa-onnx* ./scripts/wheel/sherpa-onnx-bin/bin
  109 +
  110 + - name: Build sherpa-onnx-core
  111 + shell: bash
  112 + run: |
  113 + pushd ./scripts/wheel/sherpa-onnx-core
  114 + python3 setup.py bdist_wheel --plat-name=macosx_11_0_arm64
  115 +
  116 + ls -lh dist
  117 + unzip -l dist/*.whl
  118 +
  119 + popd
  120 +
  121 + - name: Build sherpa-onnx-bin
  122 + shell: bash
  123 + run: |
  124 + pushd ./scripts/wheel/sherpa-onnx-bin
  125 + python3 setup.py bdist_wheel --plat-name=macosx_11_0_arm64
  126 +
  127 + ls -lh dist
  128 + unzip -l dist/*.whl
  129 +
  130 + popd
  131 +
  132 + - name: Collect wheels
  133 + shell: bash
  134 + run: |
  135 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl .
  136 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl .
  137 +
  138 + ls -lh *.whl
  139 +
  140 + - uses: actions/upload-artifact@v4
  141 + with:
  142 + name: wheels-core-macos-arm64
  143 + path: ./*.whl
  144 +
  145 + test:
  146 + name: test
  147 + needs: [core]
  148 + runs-on: ${{ matrix.os }}
  149 + strategy:
  150 + fail-fast: false
  151 + matrix:
  152 + os: [macos-latest]
  153 +
  154 + steps:
  155 + - uses: actions/checkout@v4
  156 + with:
  157 + fetch-depth: 0
  158 +
  159 + - name: Retrieve artifact from macos arm64
  160 + uses: actions/download-artifact@v4
  161 + with:
  162 + name: wheels-core-macos-arm64
  163 + path: /tmp/wheels
  164 +
  165 + - name: Setup Python
  166 + uses: actions/setup-python@v5
  167 + with:
  168 + python-version: "3.10"
  169 +
  170 + - name: Show
  171 + shell: bash
  172 + run: |
  173 + ls -lh /tmp/wheels
  174 +
  175 + - name: Install
  176 + shell: bash
  177 + run: |
  178 + python3 -m pip install /tmp/wheels/*.whl
  179 +
  180 + - name: Show version
  181 + shell: bash
  182 + run: |
  183 + sherpa-onnx-version
  184 +
  185 + - name: Show help
  186 + shell: bash
  187 + run: |
  188 + sherpa-onnx --help
  189 +
  190 + ls -lh $(which sherpa-onnx)
  191 + file $(which sherpa-onnx)
  192 +
  193 + otool -L $(which sherpa-onnx)
  194 + otool -l $(which sherpa-onnx)
  195 +
  196 + echo "---"
  197 +
  198 + sherpa-onnx-offline --help
  199 +
  200 + echo "---"
  201 +
  202 + sherpa-onnx-vad --help
  203 +
  204 + - name: Publish to huggingface
  205 + env:
  206 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  207 + uses: nick-fields/retry@v3
  208 + with:
  209 + max_attempts: 20
  210 + timeout_seconds: 200
  211 + shell: bash
  212 + command: |
  213 + git config --global user.email "csukuangfj@gmail.com"
  214 + git config --global user.name "Fangjun Kuang"
  215 +
  216 + rm -rf huggingface
  217 + export GIT_LFS_SKIP_SMUDGE=1
  218 + export GIT_CLONE_PROTECTION_ACTIVE=false
  219 +
  220 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  221 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  222 +
  223 + d=cpu/$SHERPA_ONNX_VERSION
  224 +
  225 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  226 + cd huggingface
  227 + git fetch
  228 + git pull
  229 + git merge -m "merge remote" --ff origin main
  230 +
  231 + mkdir -p $d
  232 +
  233 + cp -v /tmp/wheels/*.whl $d/
  234 +
  235 + git status
  236 + git add .
  237 + git commit -m "add more wheels"
  238 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  239 +
  240 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  241 + if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  242 + env:
  243 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  244 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  245 + shell: bash
  246 + run: |
  247 + opts='--break-system-packages'
  248 +
  249 + python3 -m pip install $opts --upgrade pip
  250 + python3 -m pip install $opts wheel twine==5.0.0 setuptools
  251 +
  252 + twine upload /tmp/wheels/*.whl
  253 +
17 build_wheels_macos_arm64: 254 build_wheels_macos_arm64:
  255 + needs: [core, test]
18 name: ${{ matrix.python-version }} 256 name: ${{ matrix.python-version }}
19 runs-on: ${{ matrix.os }} 257 runs-on: ${{ matrix.os }}
20 strategy: 258 strategy:
21 fail-fast: false 259 fail-fast: false
22 matrix: 260 matrix:
23 - os: [macos-13]  
24 - python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 261 + os: [macos-latest]
  262 + python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
25 263
26 steps: 264 steps:
27 - uses: actions/checkout@v4 265 - uses: actions/checkout@v4
@@ -33,10 +271,12 @@ jobs: @@ -33,10 +271,12 @@ jobs:
33 git diff . 271 git diff .
34 272
35 - name: Build wheels 273 - name: Build wheels
36 - uses: pypa/cibuildwheel@v2.21.3 274 + uses: pypa/cibuildwheel@v3.1.4
37 env: 275 env:
38 CIBW_BUILD: "${{ matrix.python-version}}-* " 276 CIBW_BUILD: "${{ matrix.python-version}}-* "
39 - CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='arm64'" 277 + CIBW_ENVIRONMENT: >
  278 + SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  279 + 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"
40 CIBW_ARCHS: "arm64" 280 CIBW_ARCHS: "arm64"
41 CIBW_BUILD_VERBOSITY: 3 281 CIBW_BUILD_VERBOSITY: 3
42 282
@@ -47,6 +287,7 @@ jobs: @@ -47,6 +287,7 @@ jobs:
47 shell: bash 287 shell: bash
48 run: | 288 run: |
49 ls -lh ./wheelhouse/ 289 ls -lh ./wheelhouse/
  290 + unzip -l ./wheelhouse/*.whl
50 291
51 - uses: actions/upload-artifact@v4 292 - uses: actions/upload-artifact@v4
52 with: 293 with:
@@ -95,10 +336,6 @@ jobs: @@ -95,10 +336,6 @@ jobs:
95 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 336 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
96 run: | 337 run: |
97 opts='--break-system-packages' 338 opts='--break-system-packages'
98 - v=${{ matrix.python-version }}  
99 - if [[ $v == cp38 || $v == cp39 ]]; then  
100 - opts=''  
101 - fi  
102 339
103 python3 -m pip install $opts --upgrade pip 340 python3 -m pip install $opts --upgrade pip
104 python3 -m pip install $opts wheel twine==5.0.0 setuptools 341 python3 -m pip install $opts wheel twine==5.0.0 setuptools
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,14 +20,247 @@ concurrency: @@ -14,14 +20,247 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
  23 + core:
  24 + runs-on: ${{ matrix.os }}
  25 + name: core
  26 + strategy:
  27 + fail-fast: false
  28 + matrix:
  29 + os: [macos-latest]
  30 +
  31 + steps:
  32 + - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
  35 +
  36 + - name: Update version
  37 + shell: bash
  38 + run: |
  39 + ./new-release.sh
  40 + git diff .
  41 + - name: Set up Python
  42 + uses: actions/setup-python@v5
  43 + with:
  44 + python-version: "3.10"
  45 +
  46 + - name: Install deps
  47 + shell: bash
  48 + run: |
  49 + python3 -m pip install setuptools wheel twine
  50 +
  51 + - name: ccache
  52 + uses: hendrikmuhs/ccache-action@v1.2
  53 + with:
  54 + key: macos-latest-sherpa-onnx-core-universal2
  55 +
  56 + - name: Configure CMake
  57 + shell: bash
  58 + run: |
  59 + export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  60 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  61 + cmake --version
  62 +
  63 + mkdir build
  64 + cd build
  65 +
  66 + cmake \
  67 + -DSHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON \
  68 + -D BUILD_SHARED_LIBS=ON \
  69 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  70 + -D CMAKE_BUILD_TYPE=Release \
  71 + -D CMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
  72 + -D CMAKE_INSTALL_PREFIX=./install \
  73 + ..
  74 +
  75 + - name: Build sherpa-onnx for macos
  76 + shell: bash
  77 + run: |
  78 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  79 +
  80 + cd build
  81 + make -j2
  82 + make install
  83 +
  84 + ls -lh lib
  85 + ls -lh bin
  86 +
  87 + file ./bin/sherpa-onnx
  88 +
  89 + rm -fv ./install/include/cargs.h
  90 + rm -fv ./install/lib/cargs.h
  91 + rm -fv ./install/lib/libcargs.dylib
  92 + rm -fv ./install/lib/libcargs.a
  93 + rm -rfv ./install/lib/pkgconfig
  94 +
  95 + - name: Copy files
  96 + shell: bash
  97 + run: |
  98 + echo 'sherpa-onnx-core'
  99 + mkdir -p scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  100 + cp -v ./build/install/lib/lib* ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  101 +
  102 + mkdir -p ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  103 + cp -v ./build/install/include/sherpa-onnx/c-api/*.h ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  104 +
  105 + echo 'sherpa-onnx-bin'
  106 +
  107 + mkdir -p ./scripts/wheel/sherpa-onnx-bin/bin
  108 + cp -v ./build/install/bin/sherpa-onnx* ./scripts/wheel/sherpa-onnx-bin/bin
  109 +
  110 + - name: Build sherpa-onnx-core
  111 + shell: bash
  112 + run: |
  113 + pushd ./scripts/wheel/sherpa-onnx-core
  114 + python3 setup.py bdist_wheel --plat-name=macosx_10_15_universal2
  115 +
  116 + ls -lh dist
  117 + unzip -l dist/*.whl
  118 +
  119 + popd
  120 +
  121 + - name: Build sherpa-onnx-bin
  122 + shell: bash
  123 + run: |
  124 + pushd ./scripts/wheel/sherpa-onnx-bin
  125 + python3 setup.py bdist_wheel --plat-name=macosx_10_15_universal2
  126 +
  127 + ls -lh dist
  128 + unzip -l dist/*.whl
  129 +
  130 + popd
  131 +
  132 + - name: Collect wheels
  133 + shell: bash
  134 + run: |
  135 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl .
  136 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl .
  137 +
  138 + ls -lh *.whl
  139 +
  140 + - uses: actions/upload-artifact@v4
  141 + with:
  142 + name: wheels-core-macos-universal
  143 + path: ./*.whl
  144 +
  145 + test:
  146 + name: test ${{ matrix.os }}
  147 + needs: [core]
  148 + runs-on: ${{ matrix.os }}
  149 + strategy:
  150 + fail-fast: false
  151 + matrix:
  152 + os: [macos-latest, macos-13]
  153 +
  154 + steps:
  155 + - uses: actions/checkout@v4
  156 + with:
  157 + fetch-depth: 0
  158 +
  159 + - name: Retrieve artifact from macos universal
  160 + uses: actions/download-artifact@v4
  161 + with:
  162 + name: wheels-core-macos-universal
  163 + path: /tmp/wheels
  164 +
  165 + - name: Setup Python
  166 + uses: actions/setup-python@v5
  167 + with:
  168 + python-version: "3.10"
  169 +
  170 + - name: Show
  171 + shell: bash
  172 + run: |
  173 + ls -lh /tmp/wheels
  174 +
  175 + - name: Install
  176 + shell: bash
  177 + run: |
  178 + python3 -m pip install /tmp/wheels/*.whl
  179 +
  180 + - name: Show version
  181 + shell: bash
  182 + run: |
  183 + sherpa-onnx-version
  184 +
  185 + - name: Show help
  186 + shell: bash
  187 + run: |
  188 + sherpa-onnx --help
  189 +
  190 + ls -lh $(which sherpa-onnx)
  191 + file $(which sherpa-onnx)
  192 +
  193 + otool -L $(which sherpa-onnx)
  194 + otool -l $(which sherpa-onnx)
  195 +
  196 + echo "---"
  197 +
  198 + sherpa-onnx-offline --help
  199 +
  200 + echo "---"
  201 +
  202 + sherpa-onnx-vad --help
  203 +
  204 + - name: Publish to huggingface
  205 + if: matrix.os == 'macos-latest'
  206 + env:
  207 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  208 + uses: nick-fields/retry@v3
  209 + with:
  210 + max_attempts: 20
  211 + timeout_seconds: 200
  212 + shell: bash
  213 + command: |
  214 + git config --global user.email "csukuangfj@gmail.com"
  215 + git config --global user.name "Fangjun Kuang"
  216 +
  217 + rm -rf huggingface
  218 + export GIT_LFS_SKIP_SMUDGE=1
  219 + export GIT_CLONE_PROTECTION_ACTIVE=false
  220 +
  221 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  222 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  223 +
  224 + d=cpu/$SHERPA_ONNX_VERSION
  225 +
  226 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  227 + cd huggingface
  228 + git fetch
  229 + git pull
  230 + git merge -m "merge remote" --ff origin main
  231 +
  232 + mkdir -p $d
  233 +
  234 + cp -v /tmp/wheels/*.whl $d/
  235 +
  236 + git status
  237 + git add .
  238 + git commit -m "add more wheels"
  239 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  240 +
  241 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  242 + if: ${{ matrix.os == 'macos-latest' && (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  243 + env:
  244 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  245 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  246 + shell: bash
  247 + run: |
  248 + opts='--break-system-packages'
  249 +
  250 + python3 -m pip install $opts --upgrade pip
  251 + python3 -m pip install $opts wheel twine==5.0.0 setuptools
  252 +
  253 + twine upload /tmp/wheels/*.whl
  254 +
17 build_wheels_macos_universal2: 255 build_wheels_macos_universal2:
  256 + needs: [core, test]
18 name: ${{ matrix.python-version }} 257 name: ${{ matrix.python-version }}
19 runs-on: ${{ matrix.os }} 258 runs-on: ${{ matrix.os }}
20 strategy: 259 strategy:
21 fail-fast: false 260 fail-fast: false
22 matrix: 261 matrix:
23 - os: [macos-13]  
24 - python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 262 + os: [macos-latest]
  263 + python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
25 264
26 steps: 265 steps:
27 - uses: actions/checkout@v4 266 - uses: actions/checkout@v4
@@ -32,11 +271,17 @@ jobs: @@ -32,11 +271,17 @@ jobs:
32 ./new-release.sh 271 ./new-release.sh
33 git diff . 272 git diff .
34 273
  274 + - name: Set macOS deployment target
  275 + run: echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV
  276 +
35 - name: Build wheels 277 - name: Build wheels
36 - uses: pypa/cibuildwheel@v2.21.3 278 + uses: pypa/cibuildwheel@v3.1.4
37 env: 279 env:
38 CIBW_BUILD: "${{ matrix.python-version}}-* " 280 CIBW_BUILD: "${{ matrix.python-version}}-* "
39 - CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64'" 281 + CIBW_ENVIRONMENT: >
  282 + MACOSX_DEPLOYMENT_TARGET=10.15
  283 + SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  284 + 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"
40 CIBW_ARCHS: "universal2" 285 CIBW_ARCHS: "universal2"
41 CIBW_BUILD_VERBOSITY: 3 286 CIBW_BUILD_VERBOSITY: 3
42 287
@@ -47,6 +292,7 @@ jobs: @@ -47,6 +292,7 @@ jobs:
47 shell: bash 292 shell: bash
48 run: | 293 run: |
49 ls -lh ./wheelhouse/ 294 ls -lh ./wheelhouse/
  295 + unzip -l ./wheelhouse/*.whl
50 296
51 - uses: actions/upload-artifact@v4 297 - uses: actions/upload-artifact@v4
52 with: 298 with:
@@ -95,10 +341,6 @@ jobs: @@ -95,10 +341,6 @@ jobs:
95 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 341 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
96 run: | 342 run: |
97 opts='--break-system-packages' 343 opts='--break-system-packages'
98 - v=${{ matrix.python-version }}  
99 - if [[ $v == cp38 || $v == cp39 ]]; then  
100 - opts=''  
101 - fi  
102 344
103 python3 -m pip install $opts --upgrade pip 345 python3 -m pip install $opts --upgrade pip
104 python3 -m pip install $opts wheel twine==5.0.0 setuptools 346 python3 -m pip install $opts wheel twine==5.0.0 setuptools
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,44 +20,266 @@ concurrency: @@ -14,44 +20,266 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
17 - build_wheels_macos_x64:  
18 - name: ${{ matrix.python-version }} 23 + core:
19 runs-on: ${{ matrix.os }} 24 runs-on: ${{ matrix.os }}
  25 + name: core
20 strategy: 26 strategy:
21 fail-fast: false 27 fail-fast: false
22 matrix: 28 matrix:
23 - os: [macos-13]  
24 - python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 29 + os: [macos-latest]
25 30
26 steps: 31 steps:
27 - uses: actions/checkout@v4 32 - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
28 35
29 - name: Update version 36 - name: Update version
30 shell: bash 37 shell: bash
31 run: | 38 run: |
32 ./new-release.sh 39 ./new-release.sh
33 git diff . 40 git diff .
  41 + - name: Set up Python
  42 + uses: actions/setup-python@v5
  43 + with:
  44 + python-version: "3.10"
34 45
35 - # see https://cibuildwheel.readthedocs.io/en/stable/changelog/  
36 - # for a list of versions  
37 - - name: Build wheels  
38 - if: matrix.python-version == 'cp37'  
39 - uses: pypa/cibuildwheel@v2.11.4 46 + - name: Install deps
  47 + shell: bash
  48 + run: |
  49 + python3 -m pip install setuptools wheel twine
  50 +
  51 + - name: ccache
  52 + uses: hendrikmuhs/ccache-action@v1.2
  53 + with:
  54 + key: macos-latest-sherpa-onnx-core-x64
  55 +
  56 + - name: Configure CMake
  57 + shell: bash
  58 + run: |
  59 + export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  60 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  61 + cmake --version
  62 +
  63 + mkdir build
  64 + cd build
  65 +
  66 + cmake \
  67 + -DSHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON \
  68 + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
  69 + -D BUILD_SHARED_LIBS=ON \
  70 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  71 + -D CMAKE_BUILD_TYPE=Release \
  72 + -D CMAKE_OSX_ARCHITECTURES='x86_64' \
  73 + -D CMAKE_INSTALL_PREFIX=./install \
  74 + ..
  75 +
  76 + - name: Build sherpa-onnx for macos
  77 + shell: bash
  78 + run: |
  79 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  80 +
  81 + cd build
  82 + make -j2
  83 + make install
  84 +
  85 + ls -lh lib
  86 + ls -lh bin
  87 +
  88 + file ./bin/sherpa-onnx
  89 +
  90 + rm -fv ./install/include/cargs.h
  91 + rm -fv ./install/lib/cargs.h
  92 + rm -fv ./install/lib/libcargs.dylib
  93 + rm -fv ./install/lib/libcargs.a
  94 + rm -rfv ./install/lib/pkgconfig
  95 +
  96 + - name: Copy files
  97 + shell: bash
  98 + run: |
  99 + echo 'sherpa-onnx-core'
  100 + mkdir -p scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  101 + cp -v ./build/install/lib/lib* ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  102 +
  103 + mkdir -p ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  104 + cp -v ./build/install/include/sherpa-onnx/c-api/*.h ./scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  105 +
  106 + echo 'sherpa-onnx-bin'
  107 +
  108 + mkdir -p ./scripts/wheel/sherpa-onnx-bin/bin
  109 + cp -v ./build/install/bin/sherpa-onnx* ./scripts/wheel/sherpa-onnx-bin/bin
  110 +
  111 + - name: Build sherpa-onnx-core
  112 + shell: bash
  113 + run: |
  114 + pushd ./scripts/wheel/sherpa-onnx-core
  115 + python3 setup.py bdist_wheel --plat-name=macosx_10_15_x86_64
  116 +
  117 + ls -lh dist
  118 + unzip -l dist/*.whl
  119 +
  120 + popd
  121 +
  122 + - name: Build sherpa-onnx-bin
  123 + shell: bash
  124 + run: |
  125 + pushd ./scripts/wheel/sherpa-onnx-bin
  126 + python3 setup.py bdist_wheel --plat-name=macosx_10_15_x86_64
  127 +
  128 + ls -lh dist
  129 + unzip -l dist/*.whl
  130 +
  131 + popd
  132 +
  133 + - name: Collect wheels
  134 + shell: bash
  135 + run: |
  136 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl .
  137 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl .
  138 +
  139 + ls -lh *.whl
  140 +
  141 + - uses: actions/upload-artifact@v4
  142 + with:
  143 + name: wheels-core-macos-x64
  144 + path: ./*.whl
  145 +
  146 + test:
  147 + name: test
  148 + needs: [core]
  149 + runs-on: ${{ matrix.os }}
  150 + strategy:
  151 + fail-fast: false
  152 + matrix:
  153 + os: [macos-13]
  154 +
  155 + steps:
  156 + - uses: actions/checkout@v4
  157 + with:
  158 + fetch-depth: 0
  159 +
  160 + - name: Retrieve artifact from macos x64
  161 + uses: actions/download-artifact@v4
  162 + with:
  163 + name: wheels-core-macos-x64
  164 + path: /tmp/wheels
  165 +
  166 + - name: Setup Python
  167 + uses: actions/setup-python@v5
  168 + with:
  169 + python-version: "3.10"
  170 +
  171 + - name: Show
  172 + shell: bash
  173 + run: |
  174 + ls -lh /tmp/wheels
  175 +
  176 + - name: Install
  177 + shell: bash
  178 + run: |
  179 + python3 -m pip install /tmp/wheels/*.whl
  180 +
  181 + - name: Show version
  182 + shell: bash
  183 + run: |
  184 + sherpa-onnx-version
  185 +
  186 + - name: Show help
  187 + shell: bash
  188 + run: |
  189 + sherpa-onnx --help
  190 +
  191 + ls -lh $(which sherpa-onnx)
  192 + file $(which sherpa-onnx)
  193 + otool -L $(which sherpa-onnx)
  194 + otool -l $(which sherpa-onnx)
  195 +
  196 + echo "---"
  197 +
  198 + sherpa-onnx-offline --help
  199 +
  200 + echo "---"
  201 +
  202 + sherpa-onnx-vad --help
  203 +
  204 + - name: Publish to huggingface
40 env: 205 env:
41 - CIBW_BUILD: "${{ matrix.python-version}}-* "  
42 - CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='x86_64'"  
43 - CIBW_ARCHS: "x86_64"  
44 - CIBW_BUILD_VERBOSITY: 3 206 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  207 + uses: nick-fields/retry@v3
  208 + with:
  209 + max_attempts: 20
  210 + timeout_seconds: 200
  211 + shell: bash
  212 + command: |
  213 + git config --global user.email "csukuangfj@gmail.com"
  214 + git config --global user.name "Fangjun Kuang"
45 215
46 - # Don't repair macOS wheels  
47 - CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" 216 + rm -rf huggingface
  217 + export GIT_LFS_SKIP_SMUDGE=1
  218 + export GIT_CLONE_PROTECTION_ACTIVE=false
  219 +
  220 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  221 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  222 +
  223 + d=cpu/$SHERPA_ONNX_VERSION
  224 +
  225 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  226 + cd huggingface
  227 + git fetch
  228 + git pull
  229 + git merge -m "merge remote" --ff origin main
  230 +
  231 + mkdir -p $d
  232 +
  233 + cp -v /tmp/wheels/*.whl $d/
  234 +
  235 + git status
  236 + git add .
  237 + git commit -m "add more wheels"
  238 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  239 +
  240 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  241 + if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  242 + env:
  243 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  244 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  245 + shell: bash
  246 + run: |
  247 + python3 -m pip install --upgrade pip
  248 + python3 -m pip install wheel twine==5.0.0 setuptools
  249 +
  250 + twine upload /tmp/wheels/*.whl
  251 +
  252 + build_wheels_macos_x64:
  253 + needs: [core, test]
  254 + name: ${{ matrix.python-version }}
  255 + runs-on: ${{ matrix.os }}
  256 + strategy:
  257 + fail-fast: false
  258 + matrix:
  259 + os: [macos-latest]
  260 + python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
  261 +
  262 + steps:
  263 + - uses: actions/checkout@v4
  264 +
  265 + - name: Update version
  266 + shell: bash
  267 + run: |
  268 + ./new-release.sh
  269 + git diff .
  270 +
  271 + - name: Set macOS deployment target
  272 + run: echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV
48 273
49 - name: Build wheels 274 - name: Build wheels
50 - if: matrix.python-version != 'cp37'  
51 - uses: pypa/cibuildwheel@v2.21.3 275 + uses: pypa/cibuildwheel@v3.1.4
52 env: 276 env:
53 CIBW_BUILD: "${{ matrix.python-version}}-* " 277 CIBW_BUILD: "${{ matrix.python-version}}-* "
54 - CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES='x86_64'" 278 + CIBW_ENVIRONMENT: >
  279 + MACOSX_DEPLOYMENT_TARGET=10.15
  280 + SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  281 + 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"
  282 +
55 CIBW_ARCHS: "x86_64" 283 CIBW_ARCHS: "x86_64"
56 CIBW_BUILD_VERBOSITY: 3 284 CIBW_BUILD_VERBOSITY: 3
57 285
@@ -62,10 +290,11 @@ jobs: @@ -62,10 +290,11 @@ jobs:
62 shell: bash 290 shell: bash
63 run: | 291 run: |
64 ls -lh ./wheelhouse/ 292 ls -lh ./wheelhouse/
  293 + unzip -l ./wheelhouse/*.whl
65 294
66 - uses: actions/upload-artifact@v4 295 - uses: actions/upload-artifact@v4
67 with: 296 with:
68 - name: wheel-${{ matrix.python-version }} 297 + name: wheel-macos-x64-${{ matrix.python-version }}
69 path: ./wheelhouse/*.whl 298 path: ./wheelhouse/*.whl
70 299
71 - name: Publish to huggingface 300 - name: Publish to huggingface
@@ -110,16 +339,8 @@ jobs: @@ -110,16 +339,8 @@ jobs:
110 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 339 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
111 run: | 340 run: |
112 opts='--break-system-packages' 341 opts='--break-system-packages'
113 - v=${{ matrix.python-version }}  
114 - if [[ $v == cp37 || $v == cp38 || $v == cp39 ]]; then  
115 - opts=''  
116 - fi  
117 342
118 python3 -m pip install $opts --upgrade pip 343 python3 -m pip install $opts --upgrade pip
119 - if [[ ${{ matrix.python-version }} == "cp37" ]]; then  
120 - python3 -m pip install $opts wheel twine setuptools  
121 - else  
122 python3 -m pip install $opts wheel twine==5.0.0 setuptools 344 python3 -m pip install $opts wheel twine==5.0.0 setuptools
123 - fi  
124 345
125 twine upload ./wheelhouse/*.whl 346 twine upload ./wheelhouse/*.whl
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,14 +20,251 @@ concurrency: @@ -14,14 +20,251 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
  23 + core:
  24 + name: core
  25 + runs-on: ${{ matrix.os }}
  26 + strategy:
  27 + fail-fast: false
  28 + matrix:
  29 + os: [windows-latest]
  30 +
  31 + steps:
  32 + - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
  35 +
  36 + - name: Update version
  37 + shell: bash
  38 + run: |
  39 + ./new-release.sh
  40 + git diff .
  41 +
  42 + - name: Setup Python
  43 + uses: actions/setup-python@v5
  44 + with:
  45 + python-version: "3.10"
  46 +
  47 + - name: Install Python dependencies
  48 + shell: bash
  49 + run: |
  50 + python3 -m pip install wheel twine==5.0.0 setuptools
  51 +
  52 + - name: Install sccache
  53 + run: choco install sccache -y
  54 +
  55 + - name: Cache sccache
  56 + uses: actions/cache@v3
  57 + with:
  58 + path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache
  59 + key: ${{ matrix.os }}-sccache-core-win32
  60 + restore-keys: |
  61 + ${{ matrix.os }}-sccache-core-win32
  62 +
  63 + - name: Configure CMake
  64 + shell: bash
  65 + run: |
  66 + mkdir build
  67 + cd build
  68 + cmake \
  69 + -D CMAKE_C_COMPILER_LAUNCHER=sccache \
  70 + -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
  71 + -A Win32 \
  72 + -D CMAKE_BUILD_TYPE=Release \
  73 + -D BUILD_SHARED_LIBS=ON \
  74 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  75 + -DCMAKE_INSTALL_PREFIX=./install \
  76 + ..
  77 +
  78 + - name: Build sherpa-onnx for windows
  79 + shell: bash
  80 + run: |
  81 + cd build
  82 + cmake --build . --config Release -- -m:2
  83 + cmake --build . --config Release --target install -- -m:2
  84 +
  85 + ls -lh ./bin/Release/sherpa-onnx.exe
  86 +
  87 + - name: Show sccache stats
  88 + run: sccache --show-stats
  89 +
  90 + - name: Show
  91 + shell: bash
  92 + run: |
  93 + echo "---bin---"
  94 + ls -lh build/install/bin
  95 + echo "---lib---"
  96 + ls -lh build/install/lib
  97 + echo "---include---"
  98 + ls -lh build/install/include
  99 +
  100 + - name: Copy files
  101 + shell: bash
  102 + run: |
  103 + cd build
  104 + echo 'sherpa-onnx-core'
  105 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  106 + cp -v ./install/lib/onnxruntime.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  107 + cp -v ./install/lib/sherpa-onnx-*.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  108 + # keep the *.lib file so users can write code to link with our dll
  109 + cp -v ./install/lib/sherpa-onnx-*.lib ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  110 +
  111 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  112 + cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  113 +
  114 + pushd ../scripts/wheel/sherpa-onnx-core
  115 + python3 setup.py bdist_wheel --plat-name=win32
  116 +
  117 + ls -lh dist
  118 +
  119 + popd
  120 +
  121 + echo 'sherpa-onnx-bin'
  122 +
  123 + mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
  124 + cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
  125 +
  126 + pushd ../scripts/wheel/sherpa-onnx-bin
  127 + python3 setup.py bdist_wheel --plat-name=win32
  128 +
  129 + ls -lh dist
  130 +
  131 + popd
  132 +
  133 + - name: Collect wheels
  134 + shell: bash
  135 + run: |
  136 + mkdir wheelhouse
  137 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
  138 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
  139 +
  140 + - uses: actions/upload-artifact@v4
  141 + with:
  142 + name: wheels-core-win-x86
  143 + path: ./wheelhouse/*.whl
  144 +
  145 + - name: Show wheels
  146 + shell: bash
  147 + run: |
  148 + ls -lh ./scripts/wheel/sherpa-onnx-core/dist
  149 + ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
  150 +
  151 + unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
  152 + echo "---"
  153 + unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
  154 +
  155 + test:
  156 + name: test
  157 + needs: [core]
  158 + runs-on: ${{ matrix.os }}
  159 + strategy:
  160 + fail-fast: false
  161 + matrix:
  162 + os: [windows-2022]
  163 +
  164 + steps:
  165 + - uses: actions/checkout@v4
  166 + with:
  167 + fetch-depth: 0
  168 +
  169 + - name: Retrieve artifact from Windows x86
  170 + uses: actions/download-artifact@v4
  171 + with:
  172 + name: wheels-core-win-x86
  173 + path: /tmp/wheels
  174 +
  175 + - name: Setup Python
  176 + uses: actions/setup-python@v5
  177 + with:
  178 + python-version: "3.10"
  179 + architecture: x86
  180 +
  181 + - name: Show
  182 + shell: bash
  183 + run: |
  184 + ls -lh /d/tmp/wheels
  185 +
  186 + - name: Install
  187 + shell: bash
  188 + run: |
  189 + python3 -m pip install /d/tmp/wheels/*.whl
  190 +
  191 + - name: Show version
  192 + shell: bash
  193 + run: |
  194 + sherpa-onnx-version
  195 +
  196 + which sherpa-onnx-version
  197 +
  198 + - name: Show help
  199 + shell: bash
  200 + run: |
  201 + sherpa-onnx --help
  202 +
  203 + echo "---"
  204 +
  205 + sherpa-onnx-offline --help
  206 +
  207 + echo "---"
  208 +
  209 + sherpa-onnx-vad --help
  210 +
  211 + - name: Publish to huggingface
  212 + env:
  213 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  214 + uses: nick-fields/retry@v3
  215 + with:
  216 + max_attempts: 20
  217 + timeout_seconds: 200
  218 + shell: bash
  219 + command: |
  220 + git config --global user.email "csukuangfj@gmail.com"
  221 + git config --global user.name "Fangjun Kuang"
  222 +
  223 + rm -rf huggingface
  224 + export GIT_LFS_SKIP_SMUDGE=1
  225 + export GIT_CLONE_PROTECTION_ACTIVE=false
  226 +
  227 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  228 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  229 +
  230 + d=cpu/$SHERPA_ONNX_VERSION
  231 +
  232 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  233 + cd huggingface
  234 + git fetch
  235 + git pull
  236 + git merge -m "merge remote" --ff origin main
  237 +
  238 + mkdir -p $d
  239 +
  240 + cp -v /d/tmp/wheels/*.whl $d/
  241 +
  242 + git status
  243 + git add .
  244 + git commit -m "add more wheels"
  245 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  246 +
  247 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  248 + if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  249 + env:
  250 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  251 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  252 + shell: bash
  253 + run: |
  254 + python3 -m pip install --upgrade pip
  255 + python3 -m pip install wheel twine==5.0.0 setuptools
  256 +
  257 + twine upload /d/tmp/wheels/*.whl
  258 +
17 build_wheels_win32: 259 build_wheels_win32:
  260 + needs: [core, test]
18 name: ${{ matrix.python-version }} 261 name: ${{ matrix.python-version }}
19 runs-on: ${{ matrix.os }} 262 runs-on: ${{ matrix.os }}
20 strategy: 263 strategy:
21 fail-fast: false 264 fail-fast: false
22 matrix: 265 matrix:
23 os: [windows-latest] 266 os: [windows-latest]
24 - python-version: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 267 + python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
25 268
26 steps: 269 steps:
27 - uses: actions/checkout@v4 270 - uses: actions/checkout@v4
@@ -34,19 +277,23 @@ jobs: @@ -34,19 +277,23 @@ jobs:
34 277
35 # see https://cibuildwheel.readthedocs.io/en/stable/changelog/ 278 # see https://cibuildwheel.readthedocs.io/en/stable/changelog/
36 # for a list of versions 279 # for a list of versions
37 - - name: Build wheels  
38 - uses: pypa/cibuildwheel@v2.21.3 280 + - name: Build wheels (cibuildwheel)
  281 + uses: pypa/cibuildwheel@v3.1.4
39 env: 282 env:
40 - CIBW_ENVIRONMENT: SHERPA_ONNX_CMAKE_ARGS="-A Win32"  
41 CIBW_BUILD: "${{ matrix.python-version}}-* " 283 CIBW_BUILD: "${{ matrix.python-version}}-* "
42 CIBW_SKIP: "*-win_amd64" 284 CIBW_SKIP: "*-win_amd64"
43 CIBW_BUILD_VERBOSITY: 3 285 CIBW_BUILD_VERBOSITY: 3
  286 + CIBW_ENVIRONMENT: >
  287 + SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  288 + 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"
44 289
45 - name: Display wheels 290 - name: Display wheels
46 shell: bash 291 shell: bash
47 run: | 292 run: |
48 ls -lh ./wheelhouse/ 293 ls -lh ./wheelhouse/
49 294
  295 + unzip -l ./wheelhouse/*.whl
  296 +
50 - uses: actions/upload-artifact@v4 297 - uses: actions/upload-artifact@v4
51 with: 298 with:
52 name: wheel-${{ matrix.python-version }} 299 name: wheel-${{ matrix.python-version }}
@@ -5,6 +5,12 @@ on: @@ -5,6 +5,12 @@ on:
5 branches: 5 branches:
6 - wheel 6 - wheel
7 workflow_dispatch: 7 workflow_dispatch:
  8 + inputs:
  9 + publish_sherpa_onnx_bin:
  10 + description: "Publish sherpa-onnx-bin"
  11 + required: false
  12 + default: "true"
  13 + type: boolean
8 14
9 env: 15 env:
10 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1 16 SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
@@ -14,13 +20,252 @@ concurrency: @@ -14,13 +20,252 @@ concurrency:
14 cancel-in-progress: true 20 cancel-in-progress: true
15 21
16 jobs: 22 jobs:
  23 + core:
  24 + name: core
  25 + runs-on: ${{ matrix.os }}
  26 + strategy:
  27 + fail-fast: false
  28 + matrix:
  29 + os: [windows-latest]
  30 +
  31 + steps:
  32 + - uses: actions/checkout@v4
  33 + with:
  34 + fetch-depth: 0
  35 +
  36 + - name: Update version
  37 + shell: bash
  38 + run: |
  39 + ./new-release.sh
  40 + git diff .
  41 +
  42 + - name: Setup Python
  43 + uses: actions/setup-python@v5
  44 + with:
  45 + python-version: "3.10"
  46 +
  47 + - name: Install Python dependencies
  48 + shell: bash
  49 + run: |
  50 + python3 -m pip install wheel twine==5.0.0 setuptools
  51 +
  52 + - name: Install sccache
  53 + run: choco install sccache -y
  54 +
  55 + - name: Cache sccache
  56 + uses: actions/cache@v3
  57 + with:
  58 + path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache
  59 + key: ${{ matrix.os }}-sccache-core
  60 + restore-keys: |
  61 + ${{ matrix.os }}-sccache-core-
  62 +
  63 + - name: Configure CMake
  64 + shell: bash
  65 + run: |
  66 + mkdir build
  67 + cd build
  68 + cmake \
  69 + -D CMAKE_C_COMPILER_LAUNCHER=sccache \
  70 + -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
  71 + -A x64 \
  72 + -D SHERPA_ONNX_ENABLE_TTS=ON \
  73 + -D CMAKE_BUILD_TYPE=Release \
  74 + -D BUILD_SHARED_LIBS=ON \
  75 + -D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  76 + -DCMAKE_INSTALL_PREFIX=./install \
  77 + ..
  78 +
  79 + - name: Build sherpa-onnx for windows
  80 + shell: bash
  81 + run: |
  82 + cd build
  83 + cmake --build . --config Release -- -m:2
  84 + cmake --build . --config Release --target install -- -m:2
  85 +
  86 + ls -lh ./bin/Release/sherpa-onnx.exe
  87 +
  88 + - name: Show sccache stats
  89 + run: sccache --show-stats
  90 +
  91 + - name: Show
  92 + shell: bash
  93 + run: |
  94 + echo "---bin---"
  95 + ls -lh build/install/bin
  96 + echo "---lib---"
  97 + ls -lh build/install/lib
  98 + echo "---include---"
  99 + ls -lh build/install/include
  100 +
  101 + - name: Copy files
  102 + shell: bash
  103 + run: |
  104 + cd build
  105 + echo 'sherpa-onnx-core'
  106 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  107 + cp -v ./install/lib/onnxruntime.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  108 + cp -v ./install/lib/sherpa-onnx-*.dll ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  109 + # keep the *.lib file so users can write code to link with our dll
  110 + cp -v ./install/lib/sherpa-onnx-*.lib ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
  111 +
  112 + mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  113 + cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
  114 +
  115 + pushd ../scripts/wheel/sherpa-onnx-core
  116 + python3 setup.py bdist_wheel --plat-name=win_amd64
  117 +
  118 + ls -lh dist
  119 +
  120 + popd
  121 +
  122 + echo 'sherpa-onnx-bin'
  123 +
  124 + mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
  125 + cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
  126 +
  127 + pushd ../scripts/wheel/sherpa-onnx-bin
  128 + python3 setup.py bdist_wheel --plat-name=win_amd64
  129 +
  130 + ls -lh dist
  131 +
  132 + popd
  133 +
  134 + - name: Collect wheels
  135 + shell: bash
  136 + run: |
  137 + mkdir wheelhouse
  138 + cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
  139 + cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
  140 +
  141 + - uses: actions/upload-artifact@v4
  142 + with:
  143 + name: wheels-core-win-x64
  144 + path: ./wheelhouse/*.whl
  145 +
  146 + - name: Show wheels
  147 + shell: bash
  148 + run: |
  149 + ls -lh ./scripts/wheel/sherpa-onnx-core/dist
  150 + ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
  151 +
  152 + unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
  153 + echo "---"
  154 + unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
  155 +
  156 + test:
  157 + name: test
  158 + needs: [core]
  159 + runs-on: ${{ matrix.os }}
  160 + strategy:
  161 + fail-fast: false
  162 + matrix:
  163 + os: [windows-2022]
  164 +
  165 + steps:
  166 + - uses: actions/checkout@v4
  167 + with:
  168 + fetch-depth: 0
  169 +
  170 + - name: Retrieve artifact from Windows x64
  171 + uses: actions/download-artifact@v4
  172 + with:
  173 + name: wheels-core-win-x64
  174 + path: /tmp/wheels
  175 +
  176 + - name: Setup Python
  177 + uses: actions/setup-python@v5
  178 + with:
  179 + python-version: "3.10"
  180 +
  181 + - name: Show
  182 + shell: bash
  183 + run: |
  184 + ls -lh /d/tmp/wheels
  185 +
  186 + - name: Install
  187 + shell: bash
  188 + run: |
  189 + python3 -m pip install /d/tmp/wheels/*.whl
  190 +
  191 + - name: Show version
  192 + shell: bash
  193 + run: |
  194 + sherpa-onnx-version
  195 +
  196 + which sherpa-onnx-version
  197 +
  198 + - name: Show help
  199 + shell: bash
  200 + run: |
  201 + sherpa-onnx --help
  202 +
  203 + echo "---"
  204 +
  205 + sherpa-onnx-offline --help
  206 +
  207 + echo "---"
  208 +
  209 + sherpa-onnx-vad --help
  210 +
  211 + which sherpa-onnx-vad
  212 +
  213 + - name: Publish to huggingface
  214 + env:
  215 + HF_TOKEN: ${{ secrets.HF_TOKEN }}
  216 + uses: nick-fields/retry@v3
  217 + with:
  218 + max_attempts: 20
  219 + timeout_seconds: 200
  220 + shell: bash
  221 + command: |
  222 + git config --global user.email "csukuangfj@gmail.com"
  223 + git config --global user.name "Fangjun Kuang"
  224 +
  225 + rm -rf huggingface
  226 + export GIT_LFS_SKIP_SMUDGE=1
  227 + export GIT_CLONE_PROTECTION_ACTIVE=false
  228 +
  229 + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  230 + echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
  231 +
  232 + d=cpu/$SHERPA_ONNX_VERSION
  233 +
  234 + git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
  235 + cd huggingface
  236 + git fetch
  237 + git pull
  238 + git merge -m "merge remote" --ff origin main
  239 +
  240 + mkdir -p $d
  241 +
  242 + cp -v /d/tmp/wheels/*.whl $d/
  243 +
  244 + git status
  245 + git add .
  246 + git commit -m "add more wheels"
  247 + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels main
  248 +
  249 + - name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
  250 + if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
  251 + env:
  252 + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  253 + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  254 + shell: bash
  255 + run: |
  256 + python3 -m pip install --upgrade pip
  257 + python3 -m pip install wheel twine==5.0.0 setuptools
  258 +
  259 + twine upload /d/tmp/wheels/*.whl
  260 +
17 build_wheels_win64: 261 build_wheels_win64:
  262 + needs: [core, test]
18 name: ${{ matrix.python-version }} 263 name: ${{ matrix.python-version }}
19 runs-on: ${{ matrix.os }} 264 runs-on: ${{ matrix.os }}
20 strategy: 265 strategy:
21 fail-fast: false 266 fail-fast: false
22 matrix: 267 matrix:
23 - os: [windows-2022] 268 + os: [windows-latest]
24 python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] 269 python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
25 270
26 steps: 271 steps:
@@ -37,10 +282,14 @@ jobs: @@ -37,10 +282,14 @@ jobs:
37 with: 282 with:
38 python-version: ${{ matrix.python-version }} 283 python-version: ${{ matrix.python-version }}
39 284
40 - - name: Build wheels 285 + - name: Build wheels (cmd)
41 shell: bash 286 shell: bash
42 run: | 287 run: |
43 - pip install setuptools wheel 288 + python3 -m pip install setuptools wheel twine
  289 +
  290 + export SHERPA_ONNX_SPLIT_PYTHON_PACKAGE=ON
  291 +
  292 + 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"
44 293
45 python3 setup.py bdist_wheel 294 python3 setup.py bdist_wheel
46 295
@@ -52,6 +301,7 @@ jobs: @@ -52,6 +301,7 @@ jobs:
52 shell: bash 301 shell: bash
53 run: | 302 run: |
54 ls -lh ./wheelhouse/ 303 ls -lh ./wheelhouse/
  304 + unzip -l ./wheelhouse/*.whl
55 305
56 - uses: actions/upload-artifact@v4 306 - uses: actions/upload-artifact@v4
57 with: 307 with:
@@ -160,6 +160,10 @@ jobs: @@ -160,6 +160,10 @@ jobs:
160 vits-piper-de_DE-miro-high 160 vits-piper-de_DE-miro-high
161 vits-piper-fr_FR-miro-high 161 vits-piper-fr_FR-miro-high
162 vits-piper-en_US-miro-high 162 vits-piper-en_US-miro-high
  163 + vits-piper-pl_PL-jarvis_wg_glos-medium
  164 + vits-piper-pl_PL-justyna_wg_glos-medium
  165 + vits-piper-pl_PL-meski_wg_glos-medium
  166 + vits-piper-pl_PL-zenski_wg_glos-medium
163 ) 167 )
164 for d in ${dirs[@]}; do 168 for d in ${dirs[@]}; do
165 src=scripts/piper/release/$d 169 src=scripts/piper/release/$d
@@ -157,7 +157,7 @@ jobs: @@ -157,7 +157,7 @@ jobs:
157 mkdir t 157 mkdir t
158 cd t 158 cd t
159 unzip ../*.whl 159 unzip ../*.whl
160 - readelf -d _sherpa_onnx*.so 160 + readelf -d sherpa_onnx/lib/_sherpa_onnx*.so
161 161
162 echo "----" 162 echo "----"
163 163
@@ -170,7 +170,7 @@ jobs: @@ -170,7 +170,7 @@ jobs:
170 mkdir t 170 mkdir t
171 cd t 171 cd t
172 unzip ../*.whl 172 unzip ../*.whl
173 - readelf -d _sherpa_onnx*.so 173 + readelf -d sherpa_onnx/lib/_sherpa_onnx*.so
174 174
175 echo "----" 175 echo "----"
176 176
@@ -39,6 +39,19 @@ jobs: @@ -39,6 +39,19 @@ jobs:
39 - os: ubuntu-latest 39 - os: ubuntu-latest
40 python-version: "3.13" 40 python-version: "3.13"
41 41
  42 + - os: ubuntu-24.04-arm
  43 + python-version: "3.8"
  44 + - os: ubuntu-24.04-arm
  45 + python-version: "3.9"
  46 + - os: ubuntu-24.04-arm
  47 + python-version: "3.10"
  48 + - os: ubuntu-24.04-arm
  49 + python-version: "3.11"
  50 + - os: ubuntu-24.04-arm
  51 + python-version: "3.12"
  52 + - os: ubuntu-24.04-arm
  53 + python-version: "3.13"
  54 +
42 - os: macos-13 55 - os: macos-13
43 python-version: "3.8" 56 python-version: "3.8"
44 57
@@ -49,8 +62,10 @@ jobs: @@ -49,8 +62,10 @@ jobs:
49 - os: macos-13 62 - os: macos-13
50 python-version: "3.11" 63 python-version: "3.11"
51 64
52 - - os: macos-14 65 + - os: macos-latest
53 python-version: "3.12" 66 python-version: "3.12"
  67 + - os: macos-latest
  68 + python-version: "3.13"
54 69
55 - os: windows-2022 70 - os: windows-2022
56 python-version: "3.7" 71 python-version: "3.7"
@@ -65,6 +80,8 @@ jobs: @@ -65,6 +80,8 @@ jobs:
65 python-version: "3.11" 80 python-version: "3.11"
66 - os: windows-2022 81 - os: windows-2022
67 python-version: "3.12" 82 python-version: "3.12"
  83 + - os: windows-latest
  84 + python-version: "3.13"
68 85
69 steps: 86 steps:
70 - uses: actions/checkout@v4 87 - uses: actions/checkout@v4
@@ -120,6 +137,10 @@ jobs: @@ -120,6 +137,10 @@ jobs:
120 cd t 137 cd t
121 unzip ../*.whl 138 unzip ../*.whl
122 139
  140 + ls -lh sherpa_onnx/lib
  141 +
  142 + file sherpa_onnx/lib/*
  143 +
123 - name: Install wheel 144 - name: Install wheel
124 shell: bash 145 shell: bash
125 run: | 146 run: |
@@ -128,14 +149,5 @@ jobs: @@ -128,14 +149,5 @@ jobs:
128 - name: Test 149 - name: Test
129 shell: bash 150 shell: bash
130 run: | 151 run: |
131 - # For windows  
132 - export PATH=/c/hostedtoolcache/windows/Python/3.7.9/x64/bin:$PATH  
133 - export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH  
134 - export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH  
135 - export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH  
136 - export PATH=/c/hostedtoolcache/windows/Python/3.11.9/x64/bin:$PATH  
137 - export PATH=/c/hostedtoolcache/windows/Python/3.12.10/x64/bin:$PATH  
138 - export PATH=/c/hostedtoolcache/windows/Python/3.13.6/x64/bin:$PATH  
139 -  
140 which sherpa-onnx 152 which sherpa-onnx
141 sherpa-onnx --help 153 sherpa-onnx --help
@@ -31,18 +31,29 @@ jobs: @@ -31,18 +31,29 @@ jobs:
31 # See https://github.com/actions/runner-images 31 # See https://github.com/actions/runner-images
32 include: 32 include:
33 - os: ubuntu-22.04 33 - os: ubuntu-22.04
34 - python-version: "3.7"  
35 - - os: ubuntu-22.04  
36 python-version: "3.8" 34 python-version: "3.8"
37 - os: ubuntu-22.04 35 - os: ubuntu-22.04
38 python-version: "3.9" 36 python-version: "3.9"
39 - os: ubuntu-22.04 37 - os: ubuntu-22.04
40 python-version: "3.10" 38 python-version: "3.10"
41 - - os: ubuntu-22.04 39 + - os: ubuntu-latest
42 python-version: "3.11" 40 python-version: "3.11"
43 - - os: ubuntu-22.04 41 + - os: ubuntu-24.04
44 python-version: "3.12" 42 python-version: "3.12"
45 - - os: ubuntu-22.04 43 + - os: ubuntu-latest
  44 + python-version: "3.13"
  45 +
  46 + - os: ubuntu-24.04-arm
  47 + python-version: "3.8"
  48 + - os: ubuntu-24.04-arm
  49 + python-version: "3.9"
  50 + - os: ubuntu-24.04-arm
  51 + python-version: "3.10"
  52 + - os: ubuntu-24.04-arm
  53 + python-version: "3.11"
  54 + - os: ubuntu-24.04-arm
  55 + python-version: "3.12"
  56 + - os: ubuntu-24.04-arm
46 python-version: "3.13" 57 python-version: "3.13"
47 58
48 - os: macos-13 59 - os: macos-13
@@ -61,8 +72,6 @@ jobs: @@ -61,8 +72,6 @@ jobs:
61 python-version: "3.13" 72 python-version: "3.13"
62 73
63 - os: windows-2022 74 - os: windows-2022
64 - python-version: "3.7"  
65 - - os: windows-2022  
66 python-version: "3.8" 75 python-version: "3.8"
67 - os: windows-2022 76 - os: windows-2022
68 python-version: "3.9" 77 python-version: "3.9"
@@ -95,29 +104,12 @@ jobs: @@ -95,29 +104,12 @@ jobs:
95 - name: Install sherpa-onnx 104 - name: Install sherpa-onnx
96 shell: bash 105 shell: bash
97 run: | 106 run: |
98 - pip install --verbose sherpa-onnx  
99 - # python3 -m pip install --verbose . 107 + pip install --verbose -U sherpa-onnx sherpa-onnx-core sherpa-onnx-bin
100 108
101 - - name: Test sherpa-onnx 109 + - name: Test sherpa-onnx-bin
102 shell: bash 110 shell: bash
103 run: | 111 run: |
104 - python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)"  
105 - python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)"  
106 -  
107 - p=$(python3 -c "from pathlib import Path; import sys; print(Path(sys.executable).parent)")  
108 - echo $p  
109 - ls -lh $p  
110 - # ls -lh $p/bin  
111 - # export PATH=$p/bin:$PATH  
112 -  
113 - # For windows  
114 - export PATH=/c/hostedtoolcache/windows/Python/3.7.9/x64/bin:$PATH  
115 - export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH  
116 - export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH  
117 - export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH  
118 - export PATH=/c/hostedtoolcache/windows/Python/3.11.9/x64/bin:$PATH  
119 - export PATH=/c/hostedtoolcache/windows/Python/3.12.10/x64/bin:$PATH  
120 - export PATH=/c/hostedtoolcache/windows/Python/3.13.6/x64/bin:$PATH 112 + sherpa-onnx-version
121 113
122 sherpa-onnx --help 114 sherpa-onnx --help
123 sherpa-onnx-keyword-spotter --help 115 sherpa-onnx-keyword-spotter --help
@@ -131,3 +123,23 @@ jobs: @@ -131,3 +123,23 @@ jobs:
131 123
132 sherpa-onnx-online-websocket-server --help 124 sherpa-onnx-online-websocket-server --help
133 sherpa-onnx-online-websocket-client --help 125 sherpa-onnx-online-websocket-client --help
  126 +
  127 + - name: Test sherpa-onnx-core
  128 + shell: bash
  129 + run: |
  130 + python3 -m sherpa_onnx --cflags
  131 + python3 -m sherpa_onnx --c-api-libs
  132 + python3 -m sherpa_onnx --c-api-libs-only-L
  133 + python3 -m sherpa_onnx --c-api-libs-only-l
  134 +
  135 + python3 -m sherpa_onnx --cxx-api-libs
  136 + python3 -m sherpa_onnx --cxx-api-libs-only-L
  137 + python3 -m sherpa_onnx --cxx-api-libs-only-l
  138 +
  139 + - name: Test sherpa-onnx
  140 + shell: bash
  141 + run: |
  142 + python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)"
  143 + python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)"
  144 + python3 -c "import sherpa_onnx; print(sherpa_onnx.OnlineRecognizer)"
  145 + python3 -c "import sherpa_onnx; print(sherpa_onnx.OfflineRecognizer)"
@@ -146,3 +146,4 @@ dict @@ -146,3 +146,4 @@ dict
146 *.npz 146 *.npz
147 voices.bin 147 voices.bin
148 kitten-nano-en-v0_1-fp16 148 kitten-nano-en-v0_1-fp16
  149 +*.egg-info
@@ -13,6 +13,11 @@ import setuptools @@ -13,6 +13,11 @@ import setuptools
13 from setuptools.command.build_ext import build_ext 13 from setuptools.command.build_ext import build_ext
14 14
15 15
  16 +def need_split_package():
  17 + ans = os.environ.get("SHERPA_ONNX_SPLIT_PYTHON_PACKAGE", None)
  18 + return ans is not None
  19 +
  20 +
16 def is_for_pypi(): 21 def is_for_pypi():
17 ans = os.environ.get("SHERPA_ONNX_IS_FOR_PYPI", None) 22 ans = os.environ.get("SHERPA_ONNX_IS_FOR_PYPI", None)
18 return ans is not None 23 return ans is not None
@@ -138,18 +143,23 @@ class BuildExtension(build_ext): @@ -138,18 +143,23 @@ class BuildExtension(build_ext):
138 if cmake_args == "": 143 if cmake_args == "":
139 cmake_args = "-DCMAKE_BUILD_TYPE=Release" 144 cmake_args = "-DCMAKE_BUILD_TYPE=Release"
140 145
141 - extra_cmake_args = f" -DCMAKE_INSTALL_PREFIX={install_dir} " 146 + extra_cmake_args = ""
  147 + if not need_split_package():
  148 + extra_cmake_args += f" -DCMAKE_INSTALL_PREFIX={install_dir} "
142 extra_cmake_args += " -DBUILD_SHARED_LIBS=ON " 149 extra_cmake_args += " -DBUILD_SHARED_LIBS=ON "
143 extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_EXE=OFF " 150 extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_EXE=OFF "
144 extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_TESTS=OFF " 151 extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_TESTS=OFF "
145 extra_cmake_args += " -DBUILD_ESPEAK_NG_EXE=OFF " 152 extra_cmake_args += " -DBUILD_ESPEAK_NG_EXE=OFF "
146 extra_cmake_args += " -DBUILD_ESPEAK_NG_TESTS=OFF " 153 extra_cmake_args += " -DBUILD_ESPEAK_NG_TESTS=OFF "
  154 +
  155 + if not need_split_package():
147 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_C_API=ON " 156 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_C_API=ON "
148 157
149 extra_cmake_args += " -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF " 158 extra_cmake_args += " -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF "
150 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF " 159 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF "
151 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PYTHON=ON " 160 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PYTHON=ON "
152 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PORTAUDIO=ON " 161 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PORTAUDIO=ON "
  162 + if not need_split_package():
153 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_WEBSOCKET=ON " 163 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_WEBSOCKET=ON "
154 164
155 if "PYTHON_EXECUTABLE" not in cmake_args: 165 if "PYTHON_EXECUTABLE" not in cmake_args:
@@ -161,10 +171,17 @@ class BuildExtension(build_ext): @@ -161,10 +171,17 @@ class BuildExtension(build_ext):
161 cmake_args = extra_cmake_args + cmake_args 171 cmake_args = extra_cmake_args + cmake_args
162 172
163 if is_windows(): 173 if is_windows():
  174 + if not need_split_package():
164 build_cmd = f""" 175 build_cmd = f"""
165 cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir} 176 cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
166 cmake --build {self.build_temp} --target install --config Release -- -m:2 177 cmake --build {self.build_temp} --target install --config Release -- -m:2
167 """ 178 """
  179 + else:
  180 + build_cmd = f"""
  181 + cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
  182 + cmake --build {self.build_temp} --target _sherpa_onnx --config Release -- -m:2
  183 + """
  184 +
168 print(f"build command is:\n{build_cmd}") 185 print(f"build command is:\n{build_cmd}")
169 ret = os.system( 186 ret = os.system(
170 f"cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}" 187 f"cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}"
@@ -172,9 +189,14 @@ class BuildExtension(build_ext): @@ -172,9 +189,14 @@ class BuildExtension(build_ext):
172 if ret != 0: 189 if ret != 0:
173 raise Exception("Failed to configure sherpa") 190 raise Exception("Failed to configure sherpa")
174 191
  192 + if not need_split_package():
175 ret = os.system( 193 ret = os.system(
176 f"cmake --build {self.build_temp} --target install --config Release -- -m:2" # noqa 194 f"cmake --build {self.build_temp} --target install --config Release -- -m:2" # noqa
177 ) 195 )
  196 + else:
  197 + ret = os.system(
  198 + f"cmake --build {self.build_temp} --target _sherpa_onnx --config Release -- -m:2" # noqa
  199 + )
178 if ret != 0: 200 if ret != 0:
179 raise Exception("Failed to build and install sherpa") 201 raise Exception("Failed to build and install sherpa")
180 else: 202 else:
@@ -185,6 +207,7 @@ class BuildExtension(build_ext): @@ -185,6 +207,7 @@ class BuildExtension(build_ext):
185 make_args = "-j4" 207 make_args = "-j4"
186 208
187 if "-G Ninja" in cmake_args: 209 if "-G Ninja" in cmake_args:
  210 + if not need_split_package():
188 build_cmd = f""" 211 build_cmd = f"""
189 cd {self.build_temp} 212 cd {self.build_temp}
190 cmake {cmake_args} {sherpa_onnx_dir} 213 cmake {cmake_args} {sherpa_onnx_dir}
@@ -193,11 +216,26 @@ class BuildExtension(build_ext): @@ -193,11 +216,26 @@ class BuildExtension(build_ext):
193 else: 216 else:
194 build_cmd = f""" 217 build_cmd = f"""
195 cd {self.build_temp} 218 cd {self.build_temp}
  219 + cmake {cmake_args} {sherpa_onnx_dir}
  220 + ninja {make_args} _sherpa_onnx
  221 + """
  222 + else:
  223 + if not need_split_package():
  224 + build_cmd = f"""
  225 + cd {self.build_temp}
196 226
197 cmake {cmake_args} {sherpa_onnx_dir} 227 cmake {cmake_args} {sherpa_onnx_dir}
198 228
199 make {make_args} install/strip 229 make {make_args} install/strip
200 """ 230 """
  231 + else:
  232 + build_cmd = f"""
  233 + cd {self.build_temp}
  234 +
  235 + cmake {cmake_args} {sherpa_onnx_dir}
  236 +
  237 + make {make_args} _sherpa_onnx
  238 + """
201 print(f"build command is:\n{build_cmd}") 239 print(f"build command is:\n{build_cmd}")
202 240
203 ret = os.system(build_cmd) 241 ret = os.system(build_cmd)
@@ -208,6 +246,25 @@ class BuildExtension(build_ext): @@ -208,6 +246,25 @@ class BuildExtension(build_ext):
208 "\nClick:\n\thttps://github.com/k2-fsa/sherpa-onnx/issues/new\n" # noqa 246 "\nClick:\n\thttps://github.com/k2-fsa/sherpa-onnx/issues/new\n" # noqa
209 ) 247 )
210 248
  249 + if need_split_package():
  250 + dst = os.path.join(f"{self.build_lib}", "sherpa_onnx", "lib")
  251 + os.system(f"mkdir {dst}")
  252 + os.system(f"dir {dst}")
  253 +
  254 + import glob
  255 +
  256 + ext = "pyd" if sys.platform.startswith("win") else "so"
  257 + pattern = os.path.join(self.build_temp, "**", f"_sherpa_onnx.*.{ext}")
  258 + matches = glob.glob(pattern, recursive=True)
  259 + print("matches", list(matches))
  260 +
  261 + for f in matches:
  262 + print(f, os.path.join(f"{self.build_lib}", "sherpa_onnx", "lib"))
  263 + shutil.copy(f"{f}", dst)
  264 + os.system(f"dir {dst}")
  265 +
  266 + return
  267 +
211 suffix = ".exe" if is_windows() else "" 268 suffix = ".exe" if is_windows() else ""
212 # Remember to also change setup.py 269 # Remember to also change setup.py
213 270
@@ -236,6 +293,3 @@ class BuildExtension(build_ext): @@ -236,6 +293,3 @@ class BuildExtension(build_ext):
236 293
237 if is_macos(): 294 if is_macos():
238 os.remove(f"{install_dir}/lib/libonnxruntime.dylib") 295 os.remove(f"{install_dir}/lib/libonnxruntime.dylib")
239 -  
240 - if is_windows():  
241 - shutil.rmtree(f"{install_dir}/lib")  
@@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll") @@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
82 82
83 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 83 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
84 84
85 -if(SHERPA_ONNX_ENABLE_PYTHON)  
86 - install(FILES ${onnxruntime_lib_files} DESTINATION ..)  
87 -else()  
88 - install(FILES ${onnxruntime_lib_files} DESTINATION lib)  
89 -endif()  
90 - 85 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
91 install(FILES ${onnxruntime_lib_files} DESTINATION bin) 86 install(FILES ${onnxruntime_lib_files} DESTINATION bin)
@@ -132,10 +132,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll") @@ -132,10 +132,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
132 132
133 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 133 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
134 134
135 -if(SHERPA_ONNX_ENABLE_PYTHON)  
136 - install(FILES ${onnxruntime_lib_files} DESTINATION ..)  
137 -else()  
138 - install(FILES ${onnxruntime_lib_files} DESTINATION lib)  
139 -endif()  
140 - 135 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
141 install(FILES ${onnxruntime_lib_files} DESTINATION bin) 136 install(FILES ${onnxruntime_lib_files} DESTINATION bin)
@@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll") @@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
82 82
83 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 83 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
84 84
85 -if(SHERPA_ONNX_ENABLE_PYTHON)  
86 - install(FILES ${onnxruntime_lib_files} DESTINATION ..)  
87 -else()  
88 - install(FILES ${onnxruntime_lib_files} DESTINATION lib)  
89 -endif()  
90 - 85 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
91 install(FILES ${onnxruntime_lib_files} DESTINATION bin) 86 install(FILES ${onnxruntime_lib_files} DESTINATION bin)
@@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll") @@ -82,10 +82,5 @@ file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
82 82
83 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 83 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
84 84
85 -if(SHERPA_ONNX_ENABLE_PYTHON)  
86 - install(FILES ${onnxruntime_lib_files} DESTINATION ..)  
87 -else()  
88 - install(FILES ${onnxruntime_lib_files} DESTINATION lib)  
89 -endif()  
90 - 85 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
91 install(FILES ${onnxruntime_lib_files} DESTINATION bin) 86 install(FILES ${onnxruntime_lib_files} DESTINATION bin)
1 function(download_pybind11) 1 function(download_pybind11)
2 include(FetchContent) 2 include(FetchContent)
3 3
4 - set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz")  
5 - set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-2.12.0.tar.gz")  
6 - set(pybind11_HASH "SHA256=bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7") 4 + set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v3.0.0.tar.gz")
  5 + set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-3.0.0.tar.gz")
  6 + set(pybind11_HASH "SHA256=453b1a3e2b266c3ae9da872411cadb6d693ac18063bd73226d96cfb7015a200c")
7 7
8 # If you don't have access to the Internet, 8 # If you don't have access to the Internet,
9 # please pre-download pybind11 9 # please pre-download pybind11
10 set(possible_file_locations 10 set(possible_file_locations
11 - $ENV{HOME}/Downloads/pybind11-2.12.0.tar.gz  
12 - ${CMAKE_SOURCE_DIR}/pybind11-2.12.0.tar.gz  
13 - ${CMAKE_BINARY_DIR}/pybind11-2.12.0.tar.gz  
14 - /tmp/pybind11-2.12.0.tar.gz  
15 - /star-fj/fangjun/download/github/pybind11-2.12.0.tar.gz 11 + $ENV{HOME}/Downloads/pybind11-3.0.0.tar.gz
  12 + ${CMAKE_SOURCE_DIR}/pybind11-3.0.0.tar.gz
  13 + ${CMAKE_BINARY_DIR}/pybind11-3.0.0.tar.gz
  14 + /tmp/pybind11-3.0.0.tar.gz
  15 + /star-fj/fangjun/download/github/pybind11-3.0.0.tar.gz
16 ) 16 )
17 17
18 foreach(f IN LISTS possible_file_locations) 18 foreach(f IN LISTS possible_file_locations)
@@ -7,6 +7,7 @@ new_version_code=20250817 @@ -7,6 +7,7 @@ new_version_code=20250817
7 7
8 old_version="1\.12\.8" 8 old_version="1\.12\.8"
9 new_version="1\.12\.9" 9 new_version="1\.12\.9"
  10 +
10 replace_str="s/$old_version/$new_version/g" 11 replace_str="s/$old_version/$new_version/g"
11 12
12 sed -i.bak "$replace_str" ./sherpa-onnx/csrc/version.cc 13 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 = @@ -22,6 +23,10 @@ find android -name "build.gradle.kts" -type f -exec sed -i.bak "s/versionCode =
22 sed -i.bak "s/ static const char \*sha1.*/ static const char \*sha1 = \"$sha1\";/g" ./sherpa-onnx/csrc/version.cc 23 sed -i.bak "s/ static const char \*sha1.*/ static const char \*sha1 = \"$sha1\";/g" ./sherpa-onnx/csrc/version.cc
23 sed -i.bak "s/ static const char \*date.*/ static const char \*date = \"$date\";/g" ./sherpa-onnx/csrc/version.cc 24 sed -i.bak "s/ static const char \*date.*/ static const char \*date = \"$date\";/g" ./sherpa-onnx/csrc/version.cc
24 25
  26 +
  27 +find scripts/wheel -name "setup.py" -type f -exec sed -i.bak "$replace_str" {} \;
  28 +sed -i.bak "$replace_str" ./setup.py
  29 +
25 sed -i.bak "$replace_str" ./build-ios-shared.sh 30 sed -i.bak "$replace_str" ./build-ios-shared.sh
26 sed -i.bak "$replace_str" ./pom.xml 31 sed -i.bak "$replace_str" ./pom.xml
27 sed -i.bak "$replace_str" ./jitpack.yml 32 sed -i.bak "$replace_str" ./jitpack.yml
@@ -24,13 +24,13 @@ git status @@ -24,13 +24,13 @@ git status
24 git diff 24 git diff
25 25
26 HF_MIRROR=hf.co 26 HF_MIRROR=hf.co
27 -linux_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl 27 +linux_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
28 linux_wheel=$src_dir/$linux_wheel_filename 28 linux_wheel=$src_dir/$linux_wheel_filename
29 29
30 -macos_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_universal2.whl 30 +macos_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_universal2.whl
31 macos_wheel=$src_dir/$macos_wheel_filename 31 macos_wheel=$src_dir/$macos_wheel_filename
32 32
33 -windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl 33 +windows_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
34 windows_x64_wheel=$src_dir/$windows_x64_wheel_filename 34 windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
35 35
36 function process_linux() { 36 function process_linux() {
@@ -26,19 +26,19 @@ pushd $src_dir @@ -26,19 +26,19 @@ pushd $src_dir
26 26
27 mkdir -p linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64 27 mkdir -p linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64
28 28
29 -linux_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl 29 +linux_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
30 linux_x64_wheel=$src_dir/$linux_x64_wheel_filename 30 linux_x64_wheel=$src_dir/$linux_x64_wheel_filename
31 31
32 -linux_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl 32 +linux_arm64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_aarch64.whl
33 linux_arm64_wheel=$src_dir/$linux_arm64_wheel_filename 33 linux_arm64_wheel=$src_dir/$linux_arm64_wheel_filename
34 34
35 -macos_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl 35 +macos_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_x86_64.whl
36 macos_x64_wheel=$src_dir/$macos_x64_wheel_filename 36 macos_x64_wheel=$src_dir/$macos_x64_wheel_filename
37 37
38 -macos_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl 38 +macos_arm64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_11_0_arm64.whl
39 macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename 39 macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename
40 40
41 -windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl 41 +windows_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
42 windows_x64_wheel=$src_dir/$windows_x64_wheel_filename 42 windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
43 43
44 windows_x86_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86.tar.bz2 44 windows_x86_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86.tar.bz2
@@ -28,8 +28,8 @@ function linux() { @@ -28,8 +28,8 @@ function linux() {
28 dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu) 28 dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu)
29 mkdir t 29 mkdir t
30 cd t 30 cd t
31 - 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  
32 - unzip sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl 31 + 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
  32 + unzip sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
33 33
34 cp -v sherpa_onnx/lib/*.so* $dst 34 cp -v sherpa_onnx/lib/*.so* $dst
35 35
@@ -40,8 +40,8 @@ function linux() { @@ -40,8 +40,8 @@ function linux() {
40 dst=$(realpath sherpa-onnx-go-linux/lib/aarch64-unknown-linux-gnu) 40 dst=$(realpath sherpa-onnx-go-linux/lib/aarch64-unknown-linux-gnu)
41 mkdir t 41 mkdir t
42 cd t 42 cd t
43 - 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  
44 - unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl 43 + 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
  44 + unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_aarch64.whl
45 45
46 cp -v sherpa_onnx/lib/*.so* $dst 46 cp -v sherpa_onnx/lib/*.so* $dst
47 47
@@ -85,8 +85,8 @@ function osx() { @@ -85,8 +85,8 @@ function osx() {
85 85
86 mkdir t 86 mkdir t
87 cd t 87 cd t
88 - 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  
89 - unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl 88 + 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
  89 + unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_x86_64.whl
90 90
91 cp -v sherpa_onnx/lib/*.dylib $dst/ 91 cp -v sherpa_onnx/lib/*.dylib $dst/
92 92
@@ -103,8 +103,8 @@ function osx() { @@ -103,8 +103,8 @@ function osx() {
103 103
104 mkdir t 104 mkdir t
105 cd t 105 cd t
106 - 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  
107 - unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl 106 + 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
  107 + unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_11_0_arm64.whl
108 108
109 cp -v sherpa_onnx/lib/*.dylib $dst/ 109 cp -v sherpa_onnx/lib/*.dylib $dst/
110 110
@@ -138,8 +138,8 @@ function windows() { @@ -138,8 +138,8 @@ function windows() {
138 dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu) 138 dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu)
139 mkdir t 139 mkdir t
140 cd t 140 cd t
141 - 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  
142 - unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl 141 + 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
  142 + unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win_amd64.whl
143 143
144 cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst 144 cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
145 145
@@ -150,8 +150,8 @@ function windows() { @@ -150,8 +150,8 @@ function windows() {
150 dst=$(realpath sherpa-onnx-go-windows/lib/i686-pc-windows-gnu) 150 dst=$(realpath sherpa-onnx-go-windows/lib/i686-pc-windows-gnu)
151 mkdir t 151 mkdir t
152 cd t 152 cd t
153 - wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl  
154 - unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl 153 + 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
  154 + unzip ./sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-win32.whl
155 155
156 cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst 156 cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
157 157
  1 +# Introduction
  2 +
  3 +This folder is for developers only.
  4 +
  5 +## sherpa-onnx-core
  6 +
  7 +It contains the scripts for building the package sherpa-onnx-core.
  8 +
  9 +```
  10 +python3 setup.py bdist_wheel --plat-name=macosx_10_15_x86_64
  11 +python3 setup.py bdist_wheel --plat-name=macosx_11_0_arm64
  12 +python3 setup.py bdist_wheel --plat-name=macosx_11_0_universal2
  13 +python3 setup.py bdist_wheel --plat-name=macosx_10_15_universal2
  14 +
  15 +python3 setup.py bdist_wheel --plat-name=win_amd64
  16 +python3 setup.py bdist_wheel --plat-name=win32
  17 +
  18 +python3 setup.py bdist_wheel --plat-name=manylinux2014_x86_64
  19 +python3 setup.py bdist_wheel --plat-name=manylinux2014_aarch64
  20 +python3 setup.py bdist_wheel --plat-name=linux_armv7l
  21 +```
  22 +
  23 +## sherpa-onnx-bin
@@ -40,9 +40,16 @@ def process(out_dir: Path, whl: Path): @@ -40,9 +40,16 @@ def process(out_dir: Path, whl: Path):
40 py_version = "3.10" 40 py_version = "3.10"
41 elif "cp311" in str(whl): 41 elif "cp311" in str(whl):
42 py_version = "3.11" 42 py_version = "3.11"
43 - else: 43 + elif "cp312" in str(whl):
44 py_version = "3.12" 44 py_version = "3.12"
  45 + elif "cp313" in str(whl):
  46 + py_version = "3.13"
  47 + elif "py3-none" in str(whl):
  48 + py_version = None
  49 + else:
  50 + assert False, f"Unknow python version in {whl}"
45 51
  52 + if py_version:
46 rpath_list = [ 53 rpath_list = [
47 f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib", 54 f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx/lib",
48 f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib", 55 f"$ORIGIN/../lib/python{py_version}/dist-packages/sherpa_onnx/lib",
@@ -52,11 +59,19 @@ def process(out_dir: Path, whl: Path): @@ -52,11 +59,19 @@ def process(out_dir: Path, whl: Path):
52 # 59 #
53 f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx.libs", 60 f"$ORIGIN/../lib/python{py_version}/site-packages/sherpa_onnx.libs",
54 ] 61 ]
  62 + else:
  63 + rpath_list = []
  64 + for p in ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]:
  65 + rpath_list.extend(
  66 + [
  67 + f"$ORIGIN/../lib/python{p}/site-packages/sherpa_onnx/lib",
  68 + f"$ORIGIN/../lib/python{p}/dist-packages/sherpa_onnx/lib",
  69 + ]
  70 + )
  71 +
55 rpaths = ":".join(rpath_list) 72 rpaths = ":".join(rpath_list)
56 73
57 - for filename in glob.glob(  
58 - f"{tmp_dir}/sherpa_onnx-*data/data/bin/*", recursive=True  
59 - ): 74 + for filename in glob.glob(f"{tmp_dir}/sherpa_onnx*data/data/bin/*", recursive=True):
60 print(filename) 75 print(filename)
61 existing_rpath = ( 76 existing_rpath = (
62 subprocess.check_output(["patchelf", "--print-rpath", filename]) 77 subprocess.check_output(["patchelf", "--print-rpath", filename])
  1 +import glob
  2 +import platform
  3 +
  4 +from setuptools import setup
  5 +
  6 +
  7 +def is_windows():
  8 + return platform.system() == "Windows"
  9 +
  10 +
  11 +bin_files = glob.glob("bin/*")
  12 +print("bin_files", bin_files)
  13 +
  14 +setup(
  15 + name="sherpa-onnx-bin",
  16 + version="1.12.9",
  17 + description="Binary executables for sherpa-onnx",
  18 + author="The sherpa-onnx development team",
  19 + url="https://github.com/k2-fsa/sherpa-onnx",
  20 + author_email="dpovey@gmail.com",
  21 + zip_safe=False,
  22 + license="Apache 2.0",
  23 + packages=[],
  24 + data_files=[("Scripts", bin_files) if is_windows() else ("bin", bin_files)],
  25 + install_requires=[
  26 + "sherpa-onnx-core==1.12.9",
  27 + ],
  28 + classifiers=[
  29 + "Programming Language :: Python :: 3",
  30 + "Operating System :: Microsoft :: Windows",
  31 + "Operating System :: POSIX :: Linux",
  32 + "Operating System :: MacOS :: MacOS X",
  33 + "Topic :: Scientific/Engineering :: Artificial Intelligence",
  34 + ],
  35 +)
  1 +recursive-include sherpa_onnx/lib *
  2 +recursive-include sherpa_onnx/include *
  1 +import platform
  2 +
  3 +from setuptools import setup
  4 +
  5 +
  6 +def is_windows():
  7 + return platform.system() == "Windows"
  8 +
  9 +
  10 +def get_binaries():
  11 + if not is_windows():
  12 + return None
  13 + libs = [
  14 + "onnxruntime.dll",
  15 + "sherpa-onnx-c-api.dll",
  16 + "sherpa-onnx-cxx-api.dll",
  17 + "sherpa-onnx-c-api.lib",
  18 + "sherpa-onnx-cxx-api.lib",
  19 + ]
  20 + prefix = "./sherpa_onnx/lib"
  21 + return [f"{prefix}/{lib}" for lib in libs]
  22 +
  23 +
  24 +setup(
  25 + name="sherpa-onnx-core",
  26 + version="1.12.9",
  27 + description="Core shared libraries for sherpa-onnx",
  28 + packages=["sherpa_onnx"],
  29 + include_package_data=True,
  30 + data_files=[("Scripts", get_binaries())] if get_binaries() else None,
  31 + author="The sherpa-onnx development team",
  32 + url="https://github.com/k2-fsa/sherpa-onnx",
  33 + author_email="dpovey@gmail.com",
  34 + zip_safe=False,
  35 + license="Apache-2.0",
  36 + classifiers=[
  37 + "Programming Language :: Python :: 3",
  38 + "Operating System :: Microsoft :: Windows",
  39 + "Operating System :: POSIX :: Linux",
  40 + "Operating System :: MacOS :: MacOS X",
  41 + "Topic :: Scientific/Engineering :: Artificial Intelligence",
  42 + ],
  43 +)
  1 +import sys
  2 +from . import _info
  3 +
  4 +
  5 +def main():
  6 + args = sys.argv[1:]
  7 + if not args:
  8 + print(
  9 + "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]"
  10 + )
  11 + sys.exit(1)
  12 +
  13 + if "--cflags" in args:
  14 + print(f"-I{_info.get_include_dir()}")
  15 + elif "--c-api-libs" in args:
  16 + lib_flags = " ".join(f"-l{lib}" for lib in _info.get_c_api_libs())
  17 + print(f"-L{_info.get_libs_dir()} {lib_flags}")
  18 + elif "--c-api-libs-only-L" in args:
  19 + print(f"-L{_info.get_libs_dir()}")
  20 + elif "--c-api-libs-only-l" in args:
  21 + print(" ".join(f"-l{lib}" for lib in _info.get_c_api_libs()))
  22 + elif "--cxx-api-libs" in args:
  23 + lib_flags = " ".join(f"-l{lib}" for lib in _info.get_cxx_api_libs())
  24 + print(f"-L{_info.get_libs_dir()} {lib_flags}")
  25 + elif "--cxx-api-libs-only-L" in args:
  26 + print(f"-L{_info.get_libs_dir()}")
  27 + elif "--cxx-api-libs-only-l" in args:
  28 + print(" ".join(f"-l{lib}" for lib in _info.get_cxx_api_libs()))
  29 + else:
  30 + print("Unknown option:", args[0])
  31 + sys.exit(1)
  32 +
  33 +
  34 +if __name__ == "__main__":
  35 + main()
  1 +from pathlib import Path
  2 +from typing import List
  3 +
  4 +_pkg_dir = Path(__file__).parent
  5 +libs_dir = _pkg_dir / "lib"
  6 +include_dir = _pkg_dir / "include"
  7 +
  8 +# List of libraries (without "lib" prefix, without extension)
  9 +# Adjust to match your actual .so/.dll/.dylib files
  10 +onnxruntime_lib = ["onnxruntime"]
  11 +c_lib = ["sherpa-onnx-c-api"] + onnxruntime_lib
  12 +cxx_lib = ["sherpa-onnx-cxx-api"] + c_lib
  13 +
  14 +
  15 +def get_include_dir() -> str:
  16 + return str(include_dir)
  17 +
  18 +
  19 +def get_libs_dir() -> str:
  20 + return str(libs_dir)
  21 +
  22 +
  23 +def get_c_api_libs() -> List[str]:
  24 + return c_lib
  25 +
  26 +
  27 +def get_cxx_api_libs() -> List[str]:
  28 + return cxx_lib
@@ -12,6 +12,7 @@ from cmake.cmake_extension import ( @@ -12,6 +12,7 @@ from cmake.cmake_extension import (
12 cmake_extension, 12 cmake_extension,
13 get_binaries, 13 get_binaries,
14 is_windows, 14 is_windows,
  15 + need_split_package,
15 ) 16 )
16 17
17 18
@@ -45,8 +46,11 @@ with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "a") as f: @@ -45,8 +46,11 @@ with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "a") as f:
45 46
46 47
47 def get_binaries_to_install(): 48 def get_binaries_to_install():
  49 + if need_split_package():
  50 + return None
  51 +
48 cmake_args = os.environ.get("SHERPA_ONNX_CMAKE_ARGS", "") 52 cmake_args = os.environ.get("SHERPA_ONNX_CMAKE_ARGS", "")
49 - if '-DSHERPA_ONNX_ENABLE_BINARY=OFF' in cmake_args: 53 + if "-DSHERPA_ONNX_ENABLE_BINARY=OFF" in cmake_args:
50 return None 54 return None
51 55
52 bin_dir = Path("build") / "sherpa_onnx" / "bin" 56 bin_dir = Path("build") / "sherpa_onnx" / "bin"
@@ -65,7 +69,7 @@ def get_binaries_to_install(): @@ -65,7 +69,7 @@ def get_binaries_to_install():
65 69
66 setuptools.setup( 70 setuptools.setup(
67 name=package_name, 71 name=package_name,
68 - python_requires=">=3.6", 72 + python_requires=">=3.7",
69 version=get_package_version(), 73 version=get_package_version(),
70 author="The sherpa-onnx development team", 74 author="The sherpa-onnx development team",
71 author_email="dpovey@gmail.com", 75 author_email="dpovey@gmail.com",
@@ -73,7 +77,13 @@ setuptools.setup( @@ -73,7 +77,13 @@ setuptools.setup(
73 "sherpa_onnx": "sherpa-onnx/python/sherpa_onnx", 77 "sherpa_onnx": "sherpa-onnx/python/sherpa_onnx",
74 }, 78 },
75 packages=["sherpa_onnx"], 79 packages=["sherpa_onnx"],
76 - data_files=[("bin", get_binaries_to_install())] if get_binaries_to_install() else None, 80 + data_files=[
  81 + ("Scripts", get_binaries_to_install())
  82 + if is_windows()
  83 + else ("bin", get_binaries_to_install())
  84 + ]
  85 + if get_binaries_to_install()
  86 + else None,
77 url="https://github.com/k2-fsa/sherpa-onnx", 87 url="https://github.com/k2-fsa/sherpa-onnx",
78 long_description=read_long_description(), 88 long_description=read_long_description(),
79 long_description_content_type="text/markdown", 89 long_description_content_type="text/markdown",
@@ -91,6 +101,7 @@ setuptools.setup( @@ -91,6 +101,7 @@ setuptools.setup(
91 ], 101 ],
92 }, 102 },
93 license="Apache licensed, as found in the LICENSE file", 103 license="Apache licensed, as found in the LICENSE file",
  104 + install_requires=["sherpa-onnx-core==1.12.9"] if need_split_package() else None,
94 ) 105 )
95 106
96 with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "r") as f: 107 with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "r") as f:
@@ -390,6 +390,10 @@ if(SHERPA_ONNX_ENABLE_BINARY) @@ -390,6 +390,10 @@ if(SHERPA_ONNX_ENABLE_BINARY)
390 390
391 if(SHERPA_ONNX_ENABLE_PYTHON) 391 if(SHERPA_ONNX_ENABLE_PYTHON)
392 target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 392 target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
  393 + elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
  394 + foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
  395 + target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
  396 + endforeach()
393 endif() 397 endif()
394 endforeach() 398 endforeach()
395 endif() 399 endif()
@@ -464,6 +468,12 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY) @@ -464,6 +468,12 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
464 foreach(exe IN LISTS exes) 468 foreach(exe IN LISTS exes)
465 target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 469 target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
466 endforeach() 470 endforeach()
  471 + elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
  472 + foreach(exe IN LISTS exes)
  473 + foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
  474 + target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
  475 + endforeach()
  476 + endforeach()
467 endif() 477 endif()
468 endif() 478 endif()
469 479
@@ -557,6 +567,12 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) @@ -557,6 +567,12 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
557 foreach(exe IN LISTS exes) 567 foreach(exe IN LISTS exes)
558 target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 568 target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
559 endforeach() 569 endforeach()
  570 + elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
  571 + foreach(exe IN LISTS exes)
  572 + foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
  573 + target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
  574 + endforeach()
  575 + endforeach()
560 endif() 576 endif()
561 endif() 577 endif()
562 578
@@ -613,6 +629,12 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY) @@ -613,6 +629,12 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
613 target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 629 target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
614 target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 630 target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
615 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 631 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
  632 + elseif(SHERPA_ONNX_SPLIT_PYTHON_PACKAGE)
  633 + foreach(ver in ITEMS 3.8 3.9 3.10 3.11 3.12 3.13 3.14)
  634 + target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
  635 + target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
  636 + target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${ver}/site-packages/sherpa_onnx/lib")
  637 + endforeach()
616 endif() 638 endif()
617 endif() 639 endif()
618 640
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 23
24 namespace sherpa_onnx { 24 namespace sherpa_onnx {
25 25
26 -class Hypothesis; 26 +struct Hypothesis;
27 27
28 class LodrFst { 28 class LodrFst {
29 public: 29 public:
@@ -114,6 +114,4 @@ if(SHERPA_ONNX_HAS_ALSA) @@ -114,6 +114,4 @@ if(SHERPA_ONNX_HAS_ALSA)
114 endif() 114 endif()
115 endif() 115 endif()
116 116
117 -install(TARGETS _sherpa_onnx  
118 - DESTINATION ../  
119 -) 117 +install(TARGETS _sherpa_onnx DESTINATION lib)
@@ -9,8 +9,6 @@ @@ -9,8 +9,6 @@
9 9
10 #include "sherpa-onnx/csrc/fast-clustering.h" 10 #include "sherpa-onnx/csrc/fast-clustering.h"
11 11
12 -#define C_CONTIGUOUS py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_  
13 -  
14 namespace sherpa_onnx { 12 namespace sherpa_onnx {
15 13
16 static void PybindFastClusteringConfig(py::module *m) { 14 static void PybindFastClusteringConfig(py::module *m) {
@@ -34,7 +32,7 @@ void PybindFastClustering(py::module *m) { @@ -34,7 +32,7 @@ void PybindFastClustering(py::module *m) {
34 "__call__", 32 "__call__",
35 [](const PyClass &self, 33 [](const PyClass &self,
36 py::array_t<float> features) -> std::vector<int32_t> { 34 py::array_t<float> features) -> std::vector<int32_t> {
37 - if (!(C_CONTIGUOUS == (features.flags() & C_CONTIGUOUS))) { 35 + if (!(features.flags() & py::array::c_style)) {
38 throw py::value_error( 36 throw py::value_error(
39 "input features should be contiguous. Please use " 37 "input features should be contiguous. Please use "
40 "np.ascontiguousarray(features)"); 38 "np.ascontiguousarray(features)");
@@ -80,7 +80,7 @@ void PybindOfflineSourceSeparation(py::module *m) { @@ -80,7 +80,7 @@ void PybindOfflineSourceSeparation(py::module *m) {
80 "process", 80 "process",
81 [](const PyClass &self, int32_t sample_rate, 81 [](const PyClass &self, int32_t sample_rate,
82 const py::array_t<float> &samples) { 82 const py::array_t<float> &samples) {
83 - if (!(C_CONTIGUOUS == (samples.flags() & C_CONTIGUOUS))) { 83 + if (!(samples.flags() & py::array::c_style)) {
84 throw py::value_error( 84 throw py::value_error(
85 "input samples should be contiguous. Please use " 85 "input samples should be contiguous. Please use "
86 "np.ascontiguousarray(samples)"); 86 "np.ascontiguousarray(samples)");
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 #ifndef SHERPA_ONNX_PYTHON_CSRC_SHERPA_ONNX_H_ 5 #ifndef SHERPA_ONNX_PYTHON_CSRC_SHERPA_ONNX_H_
6 #define SHERPA_ONNX_PYTHON_CSRC_SHERPA_ONNX_H_ 6 #define SHERPA_ONNX_PYTHON_CSRC_SHERPA_ONNX_H_
7 7
  8 +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  9 +
8 #include "pybind11/functional.h" 10 #include "pybind11/functional.h"
9 #include "pybind11/numpy.h" 11 #include "pybind11/numpy.h"
10 #include "pybind11/pybind11.h" 12 #include "pybind11/pybind11.h"
1 -from _sherpa_onnx import ( 1 +from sherpa_onnx.lib._sherpa_onnx import (
2 Alsa, 2 Alsa,
3 AudioEvent, 3 AudioEvent,
4 AudioTagging, 4 AudioTagging,
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 from pathlib import Path 3 from pathlib import Path
4 from typing import List, Optional 4 from typing import List, Optional
5 5
6 -from _sherpa_onnx import ( 6 +from sherpa_onnx.lib._sherpa_onnx import (
7 FeatureExtractorConfig, 7 FeatureExtractorConfig,
8 KeywordSpotterConfig, 8 KeywordSpotterConfig,
9 OnlineModelConfig, 9 OnlineModelConfig,
@@ -12,7 +12,7 @@ from _sherpa_onnx import ( @@ -12,7 +12,7 @@ from _sherpa_onnx import (
12 ProviderConfig, 12 ProviderConfig,
13 ) 13 )
14 14
15 -from _sherpa_onnx import KeywordSpotter as _KeywordSpotter 15 +from sherpa_onnx.lib._sherpa_onnx import KeywordSpotter as _KeywordSpotter
16 16
17 17
18 def _assert_file_exists(f: str): 18 def _assert_file_exists(f: str):
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 from pathlib import Path 3 from pathlib import Path
4 from typing import List, Optional 4 from typing import List, Optional
5 5
6 -from _sherpa_onnx import ( 6 +from sherpa_onnx.lib._sherpa_onnx import (
7 FeatureExtractorConfig, 7 FeatureExtractorConfig,
8 HomophoneReplacerConfig, 8 HomophoneReplacerConfig,
9 OfflineCanaryModelConfig, 9 OfflineCanaryModelConfig,
@@ -16,8 +16,8 @@ from _sherpa_onnx import ( @@ -16,8 +16,8 @@ from _sherpa_onnx import (
16 OfflineNemoEncDecCtcModelConfig, 16 OfflineNemoEncDecCtcModelConfig,
17 OfflineParaformerModelConfig, 17 OfflineParaformerModelConfig,
18 ) 18 )
19 -from _sherpa_onnx import OfflineRecognizer as _Recognizer  
20 -from _sherpa_onnx import ( 19 +from sherpa_onnx.lib._sherpa_onnx import OfflineRecognizer as _Recognizer
  20 +from sherpa_onnx.lib._sherpa_onnx import (
21 OfflineRecognizerConfig, 21 OfflineRecognizerConfig,
22 OfflineSenseVoiceModelConfig, 22 OfflineSenseVoiceModelConfig,
23 OfflineStream, 23 OfflineStream,
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 from pathlib import Path 2 from pathlib import Path
3 from typing import List, Optional 3 from typing import List, Optional
4 4
5 -from _sherpa_onnx import ( 5 +from sherpa_onnx.lib._sherpa_onnx import (
6 CudaConfig, 6 CudaConfig,
7 EndpointConfig, 7 EndpointConfig,
8 FeatureExtractorConfig, 8 FeatureExtractorConfig,
@@ -13,8 +13,8 @@ from _sherpa_onnx import ( @@ -13,8 +13,8 @@ from _sherpa_onnx import (
13 OnlineNeMoCtcModelConfig, 13 OnlineNeMoCtcModelConfig,
14 OnlineParaformerModelConfig, 14 OnlineParaformerModelConfig,
15 ) 15 )
16 -from _sherpa_onnx import OnlineRecognizer as _Recognizer  
17 -from _sherpa_onnx import ( 16 +from sherpa_onnx.lib._sherpa_onnx import OnlineRecognizer as _Recognizer
  17 +from sherpa_onnx.lib._sherpa_onnx import (
18 OnlineRecognizerConfig, 18 OnlineRecognizerConfig,
19 OnlineRecognizerResult, 19 OnlineRecognizerResult,
20 OnlineStream, 20 OnlineStream,