diff --git a/.github/workflows/build-bigdl-nano.yml b/.github/workflows/build-bigdl-nano.yml new file mode 100644 index 000000000000..0bd96e015ab8 --- /dev/null +++ b/.github/workflows/build-bigdl-nano.yml @@ -0,0 +1,180 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# Based on https://github.com/intel-analytics/BigDL/blob/v2.4.0/python/nano/dev/release.sh +# and the "Run Nano-init test" step of +# https://github.com/intel-analytics/BigDL/blob/v2.4.0/.github/workflows/nano_unit_tests_basic.yml +name: Build bigdl-nano wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/bigdl-nano.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-bigdl-nano.yml' + - 'docs/packages/bigdl-nano.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-bigdl-nano.yml' + - 'docs/packages/bigdl-nano.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + # python/nano/setup.py bundles prebuilt x86_64 builds of these releases (lib_urls); + # they are built from source here instead. + JEMALLOC_VERSION: '5.3.0' + GPERFTOOLS_VERSION: '2.10' + LIBJPEG_TURBO_VERSION: '3.0.0' + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: bigdl-nano + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + name: Build bigdl-nano ${{ matrix.version }} py3-none-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 60 + + env: + BIGDL_NANO_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout BigDL v${{ env.BIGDL_NANO_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: intel-analytics/BigDL + ref: v${{ env.BIGDL_NANO_VERSION }} + sparse-checkout: python/nano + persist-credentials: false + + - name: Pull manylinux_riscv64 image + run: docker pull "${MANYLINUX_RISCV64_IMAGE}" + + - name: Build jemalloc, tcmalloc and libturbojpeg, then the wheel + run: | + docker run --rm -v "$(pwd):/work" -w /work -e JEMALLOC_VERSION -e GPERFTOOLS_VERSION -e LIBJPEG_TURBO_VERSION "${MANYLINUX_RISCV64_IMAGE}" bash -c ' + set -euxo pipefail + dnf install -y -q bzip2 + mkdir -p /tmp/src + curl -fsSL "https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2" | tar xj -C /tmp/src + curl -fsSL "https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/gperftools-${GPERFTOOLS_VERSION}.tar.gz" | tar xz -C /tmp/src + curl -fsSL "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/${LIBJPEG_TURBO_VERSION}/libjpeg-turbo-${LIBJPEG_TURBO_VERSION}.tar.gz" | tar xz -C /tmp/src + jemalloc=/tmp/src/jemalloc-${JEMALLOC_VERSION} + gperftools=/tmp/src/gperftools-${GPERFTOOLS_VERSION} + libjpeg_turbo=/tmp/src/libjpeg-turbo-${LIBJPEG_TURBO_VERSION} + (cd "$jemalloc" && ./configure && make -j"$(nproc)" build_lib_shared) + (cd "$gperftools" && ./configure && make -j"$(nproc)" libtcmalloc.la) + cmake -S "$libjpeg_turbo" -B /tmp/src/libjpeg-turbo-build -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC=OFF -DWITH_JAVA=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake --build /tmp/src/libjpeg-turbo-build -j"$(nproc)" --target turbojpeg + libs=python/nano/src/bigdl/nano/libs + mkdir -p "$libs" + install -m755 -T "$jemalloc/lib/libjemalloc.so.2" "$libs/libjemalloc.so" + install -m755 -T "$(readlink -f "$gperftools/.libs/libtcmalloc.so")" "$libs/libtcmalloc.so" + install -m755 -T "$(readlink -f /tmp/src/libjpeg-turbo-build/libturbojpeg.so)" "$libs/libturbojpeg.so.0.2.0" + cp LICENSE python/nano/LICENSE + cp "$jemalloc/COPYING" python/nano/LICENSE.jemalloc + cp "$gperftools/COPYING" python/nano/LICENSE.gperftools + cp "$libjpeg_turbo/LICENSE.md" python/nano/LICENSE.libjpeg-turbo.md + cp "$libjpeg_turbo/README.ijg" python/nano/LICENSE.libjpeg-turbo-ijg + cd python/nano + pybin=/opt/python/cp311-cp311/bin + "$pybin/pip" install -q -U setuptools wheel + "$pybin/python3" setup.py bdist_wheel --plat-name manylinux_2_39_riscv64 --python-tag py3 + ' + + # bigdl-nano 2.4.0 cannot be imported on Python 3.12+ on any arch: it pins + # setuptools<66, whose pkg_resources needs the removed pkgutil.ImpImporter. + - name: Test the wheel + run: | + docker run --rm -v "$(pwd):/work" -w /tmp "${MANYLINUX_RISCV64_IMAGE}" bash -c ' + set -exo pipefail + dnf install -y -q util-linux + /opt/python/cp311-cp311/bin/python3 -m venv --upgrade-deps /tmp/venv + . /tmp/venv/bin/activate + # CLAUDE.md gotcha 640: venv seeds pip from ensurepip (24.0 on cp311, which + # vendors packaging 21.3 and has no manylinux_*_riscv64 tag at all), rejecting + # our own correctly-tagged wheel with "is not a supported wheel on this + # platform". --upgrade-deps pulls in a current pip (>=24.1) that knows riscv64. + pip install -q --extra-index-url https://pypi.riseproject.dev/simple/ --only-binary numpy /work/python/nano/dist/*.whl numpy + python - <