|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: Build hf-xet wheels (riscv64) |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'hf-xet version to build (git tag without leading v, e.g. 1.6.0)' |
| 11 | + required: true |
| 12 | + default: '1.6.0' |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - '.github/workflows/build-hf-xet.yml' |
| 16 | + - '.github/workflows/test-hf-xet.yml' |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ inputs.version || '1.6.0' }}-${{ github.head_ref || github.run_id }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read # to fetch code (actions/checkout) |
| 24 | + |
| 25 | +env: |
| 26 | + HFXET_VERSION: ${{ inputs.version || '1.6.0' }} |
| 27 | + |
| 28 | +jobs: |
| 29 | + # The 3.14 wheel is abi3 compatible, so a separate build is only needed for |
| 30 | + # 3.14t (free-threaded CPython has no stable ABI to target yet). |
| 31 | + build_wheels: |
| 32 | + name: Build hf-xet ${{ inputs.version || '1.6.0' }} ${{ matrix.python-version }}-riscv64 |
| 33 | + runs-on: ubuntu-24.04-riscv |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + platform: |
| 38 | + - target: riscv64gc-unknown-linux-gnu |
| 39 | + arch: riscv64 |
| 40 | + manylinux: 2_39 |
| 41 | + python-version: |
| 42 | + - '3.14' |
| 43 | + - '3.14t' |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout hf-xet v${{ env.HFXET_VERSION }} |
| 47 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 48 | + with: |
| 49 | + repository: huggingface/xet-core |
| 50 | + ref: v${{ env.HFXET_VERSION }} |
| 51 | + persist-credentials: false |
| 52 | + |
| 53 | + - name: Install Python |
| 54 | + uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 |
| 55 | + with: |
| 56 | + python-version: ${{ matrix.python-version }} |
| 57 | + activate-environment: true |
| 58 | + enable-cache: false |
| 59 | + |
| 60 | + - name: Install wheel tooling |
| 61 | + run: | |
| 62 | + uv pip install --upgrade pip |
| 63 | + pip install wheel |
| 64 | +
|
| 65 | + - uses: ./.github/actions/set-build-profile |
| 66 | + with: |
| 67 | + tag: v${{ env.HFXET_VERSION }} |
| 68 | + |
| 69 | + - name: Build wheels |
| 70 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 71 | + with: |
| 72 | + target: ${{ matrix.platform.target }} |
| 73 | + args: --profile ${{ env.BUILD_PROFILE }} -i ${{ matrix.python-version }} --out dist |
| 74 | + sccache: 'true' |
| 75 | + manylinux: ${{ matrix.platform.manylinux }} |
| 76 | + working-directory: hf_xet |
| 77 | + before-script-linux: | |
| 78 | + if command -v apt-get &> /dev/null; then |
| 79 | + apt-get update && apt-get install libatomic-ops-dev -y |
| 80 | + elif command -v yum &> /dev/null; then |
| 81 | + yum install libatomic_ops-devel perl-IPC-Cmd -y |
| 82 | + else |
| 83 | + echo "Neither apt-get nor yum is installed. Please install a package manager." |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | + git config --global --add safe.directory "*" |
| 87 | +
|
| 88 | + - name: Strip debug symbols into a separate file |
| 89 | + if: env.IS_RELEASE == 'true' |
| 90 | + run: | |
| 91 | + mkdir hf_xet/dbg |
| 92 | + mkdir dist |
| 93 | + pushd dist |
| 94 | + cp ../hf_xet/dist/* . |
| 95 | + LATEST_WHEEL=$(ls -tr1 *.whl | tail -n 1) |
| 96 | + WHEEL_NAME=$(basename $LATEST_WHEEL .whl) |
| 97 | + WHEEL_VERSION=$(echo $LATEST_WHEEL | cut -d '-' -f 2) |
| 98 | + SYMBOL_FILE=${WHEEL_NAME}.so.dbg |
| 99 | + wheel unpack $LATEST_WHEEL |
| 100 | + rm *.whl |
| 101 | + objcopy --only-keep-debug hf_xet-${WHEEL_VERSION}/hf_xet/hf_xet.*.so hf_xet-${WHEEL_VERSION}/hf_xet/${SYMBOL_FILE} |
| 102 | + objcopy --strip-debug hf_xet-${WHEEL_VERSION}/hf_xet/hf_xet.*.so |
| 103 | + objcopy --add-gnu-debuglink=hf_xet-${WHEEL_VERSION}/hf_xet/${SYMBOL_FILE} hf_xet-${WHEEL_VERSION}/hf_xet/hf_xet.*.so |
| 104 | + mv hf_xet-${WHEEL_VERSION}/hf_xet/${SYMBOL_FILE} ../hf_xet/dbg/${SYMBOL_FILE} |
| 105 | + wheel pack hf_xet-${WHEEL_VERSION} |
| 106 | + rm -rf hf_xet-${WHEEL_VERSION} |
| 107 | +
|
| 108 | + - name: Copy unstripped wheels to upload directory |
| 109 | + if: env.IS_RELEASE != 'true' |
| 110 | + run: | |
| 111 | + mkdir dist |
| 112 | + cp hf_xet/dist/* dist/ |
| 113 | +
|
| 114 | + - name: Upload debug symbols |
| 115 | + if: env.IS_RELEASE == 'true' |
| 116 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 117 | + with: |
| 118 | + name: hf-xet-${{ env.HFXET_VERSION }}-${{ matrix.python-version }}-riscv64-dbg |
| 119 | + path: hf_xet/dbg |
| 120 | + |
| 121 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 122 | + with: |
| 123 | + name: hf-xet-${{ env.HFXET_VERSION }}-${{ matrix.python-version }}-riscv64 |
| 124 | + path: dist/*.whl |
| 125 | + if-no-files-found: error |
| 126 | + |
| 127 | + publish: |
| 128 | + name: Publish hf-xet ${{ inputs.version || '1.6.0' }} to GitLab |
| 129 | + needs: [build_wheels] |
| 130 | + runs-on: ubuntu-latest |
| 131 | + permissions: |
| 132 | + contents: write |
| 133 | + pull-requests: write |
| 134 | + |
| 135 | + steps: |
| 136 | + - name: Publish wheels and open docs PR |
| 137 | + uses: riseproject-dev/python-wheels/actions/publish-wheels@main |
| 138 | + with: |
| 139 | + artifact-pattern: hf-xet-${{ env.HFXET_VERSION }}-*-riscv64 |
| 140 | + gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }} |
| 141 | + gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }} |
| 142 | + gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }} |
| 143 | + gh-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments