Fangjun Kuang
Committed by GitHub

Fix building RKNN wheels (#2233)

@@ -25,61 +25,105 @@ jobs: @@ -25,61 +25,105 @@ jobs:
25 with: 25 with:
26 fetch-depth: 0 26 fetch-depth: 0
27 27
28 - - name: Setup Python ${{ matrix.python-version }}  
29 - uses: actions/setup-python@v5  
30 - with:  
31 - python-version: ${{ matrix.python-version }}  
32 -  
33 - - name: Install Python dependencies  
34 - shell: bash  
35 - run: |  
36 - python3 -m pip install --upgrade pip numpy pypinyin sentencepiece setuptools wheel  
37 -  
38 - - name: ccache  
39 - uses: hendrikmuhs/ccache-action@v1.2  
40 - with:  
41 - key: ${{ matrix.os }}-rknn-linux-aarch64-wheel  
42 -  
43 - name: Download rknn-toolkit2 28 - name: Download rknn-toolkit2
44 shell: bash 29 shell: bash
45 run: | 30 run: |
46 git clone --depth 1 https://github.com/airockchip/rknn-toolkit2 31 git clone --depth 1 https://github.com/airockchip/rknn-toolkit2
47 32
48 - name: Build sherpa-onnx 33 - name: Build sherpa-onnx
49 - shell: bash  
50 - run: |  
51 - export CMAKE_CXX_COMPILER_LAUNCHER=ccache  
52 - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"  
53 - cmake --version 34 + uses: addnab/docker-run-action@v3
  35 + with:
  36 + image: quay.io/pypa/manylinux_2_28_aarch64
  37 + # image: quay.io/pypa/manylinux2014_aarch64 # it does not provide GLIBCXX 3.4.21+
  38 + options: |
  39 + --volume ${{ github.workspace }}/:/k2-fsa/sherpa-onnx
  40 + shell: bash
  41 + run: |
  42 + echo "config: ${{ matrix.config }}"
  43 + uname -a
  44 + which gcc
  45 +
  46 + gcc --version
  47 + g++ --version
  48 +
  49 + find /opt -name "python*"
  50 +
  51 + py=${{ matrix.python-version }}
  52 +
  53 + for v in $(seq 0 99); do
  54 + if [ -f /opt/_internal/cpython-$py.$v/bin/python3 ]; then
  55 + py=/opt/_internal/cpython-$py.$v/bin/python3
  56 + break
  57 + fi
  58 + done
  59 +
  60 + # there is
  61 + # py=/opt/_internal/cpython-3.13.3-nogil/bin/python3
  62 + #
  63 + echo "py: $py"
54 64
55 - echo "config: ${{ matrix.config }}"  
56 - uname -a  
57 - which gcc 65 + $py --version
58 66
59 - gcc --version  
60 - g++ --version 67 + $py -m venv my-py
61 68
62 - echo "pwd" 69 + python3 --version
  70 + which python3
63 71
64 - ls -lh 72 + source ./my-py/bin/activate
65 73
66 - sudo apt-get update -y  
67 - sudo apt-get install -y alsa-utils libasound2-dev 74 + python3 --version
  75 + which python3
68 76
69 - export SHERPA_ONNX_RKNN_TOOLKIT2_PATH=$PWD/rknn-toolkit2  
70 - export SHERPA_ONNX_RKNN_TOOLKIT2_LIB_DIR=$SHERPA_ONNX_RKNN_TOOLKIT2_PATH/rknpu2/runtime/Linux/librknn_api/aarch64  
71 - export CPLUS_INCLUDE_PATH=$SHERPA_ONNX_RKNN_TOOLKIT2_PATH/rknpu2/runtime/Linux/librknn_api/include:$CPLUS_INCLUDE_PATH 77 + python3 -m pip install wheel twine setuptools
72 78
73 - export SHERPA_ONNX_ENABLE_ALSA=1 79 + echo "pwd"
74 80
75 - export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_RKNN=ON"  
76 - python3 setup.py bdist_wheel 81 + cd /k2-fsa/sherpa-onnx/
  82 +
  83 + ls -lh
  84 +
  85 + cmake --version
  86 +
  87 + echo "config: ${{ matrix.config }}"
  88 + uname -a
  89 + echo "pwd"
  90 +
  91 + git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
  92 + pushd alsa-lib
  93 + ./gitcompile
  94 + popd
  95 +
  96 + ls -lh $PWD/alsa-lib/src/.libs
  97 +
  98 + strings $PWD/alsa-lib/src/.libs/libasound.so.2.0.0 | grep "^GLIBC"
  99 +
  100 + export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
  101 + export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
  102 +
  103 +
  104 + export SHERPA_ONNX_RKNN_TOOLKIT2_PATH=$PWD/rknn-toolkit2
  105 + export SHERPA_ONNX_RKNN_TOOLKIT2_LIB_DIR=$SHERPA_ONNX_RKNN_TOOLKIT2_PATH/rknpu2/runtime/Linux/librknn_api/aarch64
  106 + export CPLUS_INCLUDE_PATH=$SHERPA_ONNX_RKNN_TOOLKIT2_PATH/rknpu2/runtime/Linux/librknn_api/include:$CPLUS_INCLUDE_PATH
  107 +
  108 + export SHERPA_ONNX_ENABLE_ALSA=1
  109 +
  110 + export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_RKNN=ON"
  111 + python3 setup.py bdist_wheel
77 112
78 - name: Display results 113 - name: Display results
79 shell: bash 114 shell: bash
80 run: | 115 run: |
81 ls -lh dist 116 ls -lh dist
82 117
  118 + - name: Show glibc versions
  119 + shell: bash
  120 + run: |
  121 + mkdir t
  122 + cp dist/*.whl t
  123 + cd t
  124 + unzip ./*.whl
  125 + strings sherpa_onnx-*.data/data/bin/sherpa-onnx | grep GLIBC
  126 +
83 - name: Publish to huggingface 127 - name: Publish to huggingface
84 env: 128 env:
85 HF_TOKEN: ${{ secrets.HF_TOKEN }} 129 HF_TOKEN: ${{ secrets.HF_TOKEN }}