Repository navigation
.github/workflows/build-wheel.yml #6
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| on: | |
| workflow_call: | |
| inputs: | |
| host-platform: | |
| required: true | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| host-platform: | |
| description: "Host platform to build wheels for" | |
| required: true | |
| type: choice | |
| options: | |
| - linux-64 | |
| - linux-aarch64 | |
| - win-64 | |
| default: linux-64 | |
| defaults: | |
| run: | |
| shell: bash --noprofile --norc -xeuo pipefail {0} | |
| permissions: | |
| contents: read # This is required for actions/checkout | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| # - "3.14" | |
| # - "3.14t" | |
| name: py${{ matrix.python-version }} | |
| runs-on: ${{ (inputs.host-platform == 'linux-64' && 'linux-amd64-cpu8') || | |
| (inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') || | |
| (inputs.host-platform == 'win-64' && 'windows-2022') }} | |
| steps: | |
| - name: Checkout ${{ github.event.repository.name }} | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install latest rapidsai/sccache | |
| if: ${{ startsWith(inputs.host-platform, 'linux') }} | |
| run: | | |
| curl -fsSL "https://github.com/rapidsai/sccache/releases/latest/download/sccache-$(uname -m)-unknown-linux-musl.tar.gz" \ | |
| | sudo tar -C /usr/local/bin -xvzf - --wildcards --strip-components=1 -x '*/sccache' | |
| echo "SCCACHE_PATH=/usr/local/bin/sccache" >> "$GITHUB_ENV" | |
| echo "SCCACHE_GHA_USE_PREPROCESSOR_CACHE_MODE=true" >> "$GITHUB_ENV" | |
| # xref: https://github.com/orgs/community/discussions/42856#discussioncomment-7678867 | |
| - name: Adding additional GHA cache-related env vars | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| core.exportVariable('ACTIONS_CACHE_SERVICE_V2', 'on'); | |
| core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'] || ''); | |
| core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL'] || ''); | |
| core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'] || ''); | |
| core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'] || ''); | |
| - name: Setup proxy cache | |
| uses: nv-gha-runners/setup-proxy-cache@main | |
| continue-on-error: true | |
| # Skip cache on GitHub-hosted Windows runners. | |
| if: ${{ inputs.host-platform != 'win-64' }} | |
| with: | |
| enable-apt: true | |
| - name: Set up Python | |
| id: setup-python1 | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| # WAR: setup-python is not relocatable, and cibuildwheel hard-wires to 3.12... | |
| # see https://github.com/actions/setup-python/issues/871 | |
| python-version: "3.12" | |
| - name: Set up MSVC | |
| if: ${{ startsWith(inputs.host-platform, 'win') }} | |
| uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 | |
| - name: Set up yq | |
| # GitHub made an unprofessional decision to not provide it in their Windows VMs, | |
| # see https://github.com/actions/runner-images/issues/7443. | |
| if: ${{ startsWith(inputs.host-platform, 'win') }} | |
| env: | |
| YQ_VERSION: v4.52.5 | |
| YQ_SHA256: 47594981f3848a4b4447494adeca9555f908f7cf0a89c4da3fd0243a4631da1c | |
| YQ_DIR: yq | |
| shell: pwsh -command ". '{0}'" | |
| run: | | |
| $yqUrl = "https://github.com/mikefarah/yq/releases/download/${env:YQ_VERSION}/yq_windows_amd64.exe" | |
| mkdir -Force -ErrorAction SilentlyContinue "${env:YQ_DIR}" | Out-Null | |
| Invoke-WebRequest -UseBasicParsing -OutFile "${env:YQ_DIR}/yq.exe" -Uri "$yqUrl" | |
| $hash = (Get-FileHash -Algorithm SHA256 "${env:YQ_DIR}/yq.exe").Hash.ToLower() | |
| if ($hash -ne $env:YQ_SHA256) { | |
| Write-Error "SHA256 mismatch for yq: expected $env:YQ_SHA256, got $hash" | |
| exit 1 | |
| } | |
| ls -l $env:YQ_DIR | |
| echo "$((Get-Location).Path)\\$env:YQ_DIR" >> $env:GITHUB_PATH | |
| $env:Path += ";$((Get-Location).Path)\\$env:YQ_DIR" | |
| yq --version | |
| - name: Set environment variables | |
| env: | |
| HOST_PLATFORM: ${{ inputs.host-platform }} | |
| PY_VER: ${{ matrix.python-version }} | |
| SHA: ${{ github.sha }} | |
| run: ./ci/tools/env-vars build | |
| - name: Dump environment | |
| run: | | |
| env | |
| - name: Install twine | |
| run: | | |
| pip install twine | |
| - name: Build nvmath-python wheel | |
| uses: pypa/cibuildwheel@ee02a1537ce3071a004a6b08c41e72f0fdc42d9a # v3.4.0 | |
| with: | |
| package-dir: . | |
| output-dir: ${{ env.NVMATH_PYTHON_ARTIFACTS_DIR }} | |
| env: | |
| CIBW_BUILD: ${{ env.CIBW_BUILD }} | |
| # CIBW mounts the host filesystem under /host | |
| CIBW_ENVIRONMENT_LINUX: > | |
| NVMATH_PYTHON_PARALLEL_LEVEL=${{ env.NVMATH_PYTHON_PARALLEL_LEVEL }} | |
| CC="/host/${{ env.SCCACHE_PATH }} cc" | |
| CXX="/host/${{ env.SCCACHE_PATH }} c++" | |
| SCCACHE_GHA_ENABLED=true | |
| ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} | |
| ACTIONS_RUNTIME_URL=${{ env.ACTIONS_RUNTIME_URL }} | |
| ACTIONS_RESULTS_URL=${{ env.ACTIONS_RESULTS_URL }} | |
| ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }} | |
| ACTIONS_CACHE_SERVICE_V2=${{ env.ACTIONS_CACHE_SERVICE_V2 }} | |
| SCCACHE_GHA_USE_PREPROCESSOR_CACHE_MODE=${{ env.SCCACHE_GHA_USE_PREPROCESSOR_CACHE_MODE }} | |
| SCCACHE_DIR=/host/${{ env.SCCACHE_DIR }} | |
| SCCACHE_CACHE_SIZE=${{ env.SCCACHE_CACHE_SIZE }} | |
| CIBW_ENVIRONMENT_WINDOWS: > | |
| NVMATH_PYTHON_PARALLEL_LEVEL=${{ env.NVMATH_PYTHON_PARALLEL_LEVEL }} | |
| # check cache stats before leaving cibuildwheel | |
| CIBW_BEFORE_TEST_LINUX: > | |
| "/host${{ env.SCCACHE_PATH }}" --show-adv-stats && | |
| "/host${{ env.SCCACHE_PATH }}" --show-stats --stats-format=json > /host/${{ github.workspace }}/sccache_core.json | |
| # force the test stage to be run (so that before-test is not skipped) | |
| # TODO: we might want to think twice on adding this, it does a lot of | |
| # things before reaching this command. | |
| CIBW_TEST_COMMAND: > | |
| echo "ok!" | |
| - name: Report sccache stats (nvmath-python) | |
| if: ${{ inputs.host-platform != 'win-64' }} | |
| uses: ./.github/actions/sccache-summary | |
| with: | |
| json-file: sccache_core.json | |
| label: "nvmath-python" | |
| build-step: "Build nvmath-python wheel" | |
| - name: List the nvmath-python artifacts directory | |
| run: | | |
| if [[ "${{ inputs.host-platform }}" == win* ]]; then | |
| export CHOWN=chown | |
| else | |
| export CHOWN="sudo chown" | |
| fi | |
| $CHOWN -R $(whoami) ${{ env.NVMATH_PYTHON_ARTIFACTS_DIR }} | |
| ls -lahR ${{ env.NVMATH_PYTHON_ARTIFACTS_DIR }} | |
| - name: Set up Python | |
| id: setup-python2 | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: verify free-threaded build | |
| if: endsWith(matrix.python-version, 't') | |
| run: python -c 'import sys; assert not sys._is_gil_enabled()' | |
| - name: Set up Python include paths | |
| run: | | |
| if [[ "${{ inputs.host-platform }}" == linux* ]]; then | |
| echo "CPLUS_INCLUDE_PATH=${Python3_ROOT_DIR}/include/python${{ matrix.python-version }}" >> $GITHUB_ENV | |
| elif [[ "${{ inputs.host-platform }}" == win* ]]; then | |
| echo "CL=/I\"${Python3_ROOT_DIR}\include\python${{ matrix.python-version }}\"" >> $GITHUB_ENV | |
| fi | |
| # For caching | |
| echo "PY_EXT_SUFFIX=$(python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")" >> $GITHUB_ENV | |
| - name: Check nvmath-python wheel | |
| run: | | |
| twine check --strict ${{ env.NVMATH_PYTHON_ARTIFACTS_DIR }}/*.whl | |
| - name: Upload nvmath-python build artifacts | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: ${{ env.NVMATH_PYTHON_ARTIFACT_NAME }} | |
| path: ${{ env.NVMATH_PYTHON_ARTIFACTS_DIR }}/*.whl | |
| if-no-files-found: error |