build-wheels-linux.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. name: build-wheels-linux
  2. on:
  3. push:
  4. branches:
  5. - wheel
  6. tags:
  7. - '*'
  8. workflow_dispatch:
  9. env:
  10. SHERPA_NCNN_IS_IN_GITHUB_ACTIONS: 1
  11. concurrency:
  12. group: build-wheels-linux-${{ github.ref }}
  13. cancel-in-progress: true
  14. jobs:
  15. build_wheels_linux:
  16. name: ${{ matrix.python-version }}
  17. runs-on: ${{ matrix.os }}
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. os: [ubuntu-latest]
  22. python-version: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312"]
  23. steps:
  24. - uses: actions/checkout@v4
  25. # see https://cibuildwheel.readthedocs.io/en/stable/changelog/
  26. # for a list of versions
  27. - name: Build wheels
  28. uses: pypa/cibuildwheel@v2.15.0
  29. env:
  30. CIBW_BEFORE_ALL: |
  31. git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
  32. cd alsa-lib
  33. ./gitcompile
  34. cd ..
  35. echo "PWD"
  36. ls -lh /project/alsa-lib/src/.libs
  37. CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_NCNN_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_ncnn/lib:$SHERPA_NCNN_ALSA_LIB_DIR SHERPA_NCNN_MAKE_ARGS="VERBOSE=1" SHERPA_NCNN_ENABLE_ALSA=1
  38. CIBW_BUILD: "${{ matrix.python-version}}-* "
  39. CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
  40. CIBW_BUILD_VERBOSITY: 3
  41. - name: Display wheels
  42. shell: bash
  43. run: |
  44. ls -lh ./wheelhouse/
  45. - name: Install patchelf
  46. if: matrix.os == 'ubuntu-latest'
  47. shell: bash
  48. run: |
  49. sudo apt-get update -q
  50. sudo apt-get install -q -y patchelf
  51. patchelf --help
  52. - name: Patch wheels
  53. shell: bash
  54. if: matrix.os == 'ubuntu-latest'
  55. run: |
  56. mkdir ./wheels
  57. sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels
  58. ls -lh ./wheels/
  59. rm -rf ./wheelhouse
  60. mv ./wheels ./wheelhouse
  61. - uses: actions/upload-artifact@v4
  62. with:
  63. name: ${{ matrix.python-version }}
  64. path: ./wheelhouse/*.whl
  65. - name: Publish to huggingface
  66. if: matrix.python-version == 'cp38'
  67. env:
  68. HF_TOKEN: ${{ secrets.HF_TOKEN }}
  69. uses: nick-fields/retry@v3
  70. with:
  71. max_attempts: 20
  72. timeout_seconds: 200
  73. shell: bash
  74. command: |
  75. git config --global user.email "csukuangfj@gmail.com"
  76. git config --global user.name "Fangjun Kuang"
  77. rm -rf huggingface
  78. export GIT_LFS_SKIP_SMUDGE=1
  79. git clone https://huggingface.co/csukuangfj/sherpa-ncnn-wheels huggingface
  80. cd huggingface
  81. git fetch
  82. git pull
  83. git merge -m "merge remote" --ff origin main
  84. cp -v ../wheelhouse/*.whl .
  85. git status
  86. git add .
  87. git commit -m "add more wheels"
  88. git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-ncnn-wheels main
  89. - name: Publish wheels to PyPI
  90. env:
  91. TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  92. TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  93. run: |
  94. python3 -m pip install --upgrade pip
  95. python3 -m pip install wheel twine setuptools
  96. twine upload ./wheelhouse/*.whl
  97. - name: Build sdist
  98. if: matrix.python-version == 'cp38'
  99. shell: bash
  100. run: |
  101. python3 setup.py sdist
  102. ls -lh dist/*
  103. - name: Publish sdist to PyPI
  104. if: matrix.python-version == 'cp38'
  105. env:
  106. TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
  107. TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  108. run: |
  109. python3 -m pip install --upgrade pip
  110. python3 -m pip install wheel twine setuptools
  111. twine upload dist/sherpa*.tar.gz