|
| 1 | +name: Dist Paddle |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [paddle] |
| 5 | + tags: ["v*"] |
| 6 | + pull_request: |
| 7 | + merge_group: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + PYTHONDEVMODE: "1" |
| 19 | + PYTHONUNBUFFERED: "1" |
| 20 | + COLUMNS: "100" |
| 21 | + FORCE_COLOR: "1" |
| 22 | + CLICOLOR_FORCE: "1" |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-sdist: |
| 26 | + name: Build SDist |
| 27 | + runs-on: macos-latest |
| 28 | + timeout-minutes: 30 |
| 29 | + env: |
| 30 | + # `NO_VERSION_LABEL=ON` disables embedding the toolchain / git commit hash in version metadata. |
| 31 | + # Otherwise, the version of the SDist has a git hash suffix (e.g., 0.1.0+gitabcdef12), |
| 32 | + # but the package built from the SDist has no way to get the git hash (it is not a git repo), |
| 33 | + # leading to inconsistent versions between SDist and built packages (+gitabcdef12 vs. +gitunknown). |
| 34 | + NO_VERSION_LABEL: "ON" |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v5 |
| 39 | + with: |
| 40 | + fetch-depth: 1 |
| 41 | + submodules: recursive |
| 42 | + |
| 43 | + - name: Setup Python and uv with caching |
| 44 | + id: setup-uv |
| 45 | + uses: astral-sh/setup-uv@v7 |
| 46 | + with: |
| 47 | + python-version: "3.12" |
| 48 | + activate-environment: true |
| 49 | + |
| 50 | + - name: Build SDist |
| 51 | + run: | |
| 52 | + uv run --no-project --with=build -m -- build --sdist --outdir=dist |
| 53 | +
|
| 54 | + - name: Setup ccache |
| 55 | + uses: hendrikmuhs/ccache-action@v1 |
| 56 | + with: |
| 57 | + create-symlink: true |
| 58 | + evict-old-files: "7d" |
| 59 | + append-timestamp: false |
| 60 | + key: sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }} |
| 61 | + restore-keys: | |
| 62 | + sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }} |
| 63 | + sdist-${{ runner.os }}-${{ runner.arch }} |
| 64 | + ${{ runner.os }}-${{ runner.arch }} |
| 65 | +
|
| 66 | + - name: Test SDist buildable |
| 67 | + run: | |
| 68 | + TEMP_DIR="$(mktemp -d -t tilelang-sdist-test)" |
| 69 | + cp -r dist "${TEMP_DIR}/dist" |
| 70 | + cd "${TEMP_DIR}" |
| 71 | + uv pip install -v dist/*.tar.gz |
| 72 | + # python3 -c "import tilelang; print(tilelang.__version__)" |
| 73 | +
|
| 74 | + - name: Upload SDist |
| 75 | + # Not PR to save artifact storage, as SDist is only needed for releases. |
| 76 | + uses: actions/upload-artifact@v5 |
| 77 | + with: |
| 78 | + name: sdist |
| 79 | + path: dist/*.tar.gz |
| 80 | + if-no-files-found: error |
| 81 | + |
| 82 | + build-wheels: |
| 83 | + name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.target.runner }} with ${{ matrix.target.toolkit }} |
| 84 | + strategy: |
| 85 | + matrix: |
| 86 | + target: |
| 87 | + - { runner: ubuntu-latest, toolkit: "CUDA-12.1" } |
| 88 | + - { runner: ubuntu-24.04-arm, toolkit: "CUDA-12.8" } |
| 89 | + - { runner: macos-latest, toolkit: "Metal" } |
| 90 | + python-version: |
| 91 | + # Wheels are built with Python 3.8 Limited API, they should work with all Python >= 3.8. |
| 92 | + # Only build wheels against Python 3.8 Limited API to save CI resources. |
| 93 | + # FIXME: Here we use Python 3.9 because our dependency `apache-tvm-ffi` claims to support |
| 94 | + # Python 3.8 but it depends on a version of `ml-dtypes` that requires Python >= 3.9. |
| 95 | + - "3.9" |
| 96 | + fail-fast: false |
| 97 | + timeout-minutes: 120 |
| 98 | + runs-on: ${{ matrix.target.runner }} |
| 99 | + env: |
| 100 | + NO_VERSION_LABEL: ${{ github.event_name == 'release' && 'OFF' || 'ON' }} |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Checkout repository |
| 104 | + uses: actions/checkout@v5 |
| 105 | + with: |
| 106 | + fetch-depth: 1 |
| 107 | + submodules: recursive |
| 108 | + |
| 109 | + - name: Setup ccache |
| 110 | + uses: hendrikmuhs/ccache-action@v1 |
| 111 | + with: |
| 112 | + create-symlink: true |
| 113 | + evict-old-files: "7d" |
| 114 | + append-timestamp: false |
| 115 | + key: wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}-${{ hashFiles('**/*.cc') }} |
| 116 | + restore-keys: | |
| 117 | + wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}-${{ hashFiles('**/*.cc') }} |
| 118 | + wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }} |
| 119 | + wheel-${{ runner.os }}-${{ runner.arch }} |
| 120 | + ${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }} |
| 121 | + ${{ runner.os }}-${{ runner.arch }} |
| 122 | +
|
| 123 | + - name: Set CIBW_BUILD |
| 124 | + run: | |
| 125 | + PYTHON_VERSION="${{ matrix.python-version }}" |
| 126 | + PYTHON_VERSION_MAJMIN="$(echo "${PYTHON_VERSION}" | cut -d '.' -f-2)" |
| 127 | + PYTHON_VERSION_MAJMIN_NODOT="${PYTHON_VERSION_MAJMIN//./}" |
| 128 | + echo "CIBW_BUILD=cp${PYTHON_VERSION_MAJMIN_NODOT}-*" | tee -a "${GITHUB_ENV}" |
| 129 | +
|
| 130 | + if [[ "${{ matrix.target.toolkit }}" == *"CUDA"* ]]; then |
| 131 | + CUDA_VERSION="${{ matrix.target.toolkit }}" |
| 132 | + CUDA_VERSION="${CUDA_VERSION#CUDA-}" |
| 133 | + echo "CUDA_VERSION=${CUDA_VERSION}" | tee -a "${GITHUB_ENV}" |
| 134 | + fi |
| 135 | +
|
| 136 | + if [[ "${{ runner.os }}" == "Linux" ]]; then |
| 137 | + HOST_CCACHE_DIR="$(ccache --get-config cache_dir)" |
| 138 | + echo "CIBW_BEFORE_BUILD_LINUX=yum install -y ccache && ccache -o cache_dir=/host${HOST_CCACHE_DIR}" | tee -a "${GITHUB_ENV}" |
| 139 | + fi |
| 140 | +
|
| 141 | + - name: Build wheels |
| 142 | + |
| 143 | + with: |
| 144 | + package-dir: . |
| 145 | + output-dir: wheelhouse |
| 146 | + config-file: "{package}/pyproject.toml" |
| 147 | + |
| 148 | + - name: Upload wheels |
| 149 | + # Not PR to save artifact storage, as wheels are only needed for releases. |
| 150 | + uses: actions/upload-artifact@v5 |
| 151 | + with: |
| 152 | + name: wheels-${{ matrix.python-version }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }} |
| 153 | + path: wheelhouse/*.whl |
| 154 | + if-no-files-found: error |
| 155 | + |
| 156 | + list-artifacts: |
| 157 | + name: List artifacts |
| 158 | + # Not PR to save artifact storage, as artifacts are only needed for releases. |
| 159 | + runs-on: ubuntu-latest |
| 160 | + needs: [build-sdist, build-wheels] |
| 161 | + timeout-minutes: 15 |
| 162 | + steps: |
| 163 | + - name: Download built SDist |
| 164 | + uses: actions/download-artifact@v6 |
| 165 | + with: |
| 166 | + # unpacks default artifact into dist/ |
| 167 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 168 | + name: sdist |
| 169 | + path: dist |
| 170 | + |
| 171 | + - name: Download built wheels |
| 172 | + uses: actions/download-artifact@v6 |
| 173 | + with: |
| 174 | + pattern: wheels-* |
| 175 | + path: dist |
| 176 | + merge-multiple: true |
| 177 | + |
| 178 | + - name: List distributions |
| 179 | + run: ls -lh dist/* |
| 180 | + |
| 181 | + - name: Upload artifacts |
| 182 | + uses: actions/upload-artifact@v5 |
| 183 | + with: |
| 184 | + name: artifacts |
| 185 | + path: dist/* |
| 186 | + if-no-files-found: error |
| 187 | + |
| 188 | + publish-pypi: |
| 189 | + runs-on: ubuntu-latest |
| 190 | + name: Publish to PyPI |
| 191 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 192 | + needs: |
| 193 | + - list-artifacts |
| 194 | + permissions: |
| 195 | + id-token: write |
| 196 | + |
| 197 | + steps: |
| 198 | + - name: Retrieve release distributions |
| 199 | + uses: actions/download-artifact@v6 |
| 200 | + with: |
| 201 | + name: artifacts |
| 202 | + path: dist/ |
| 203 | + |
| 204 | + - name: Publish release distributions to PyPI |
| 205 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 206 | + |
| 207 | + publish-release: |
| 208 | + runs-on: ubuntu-latest |
| 209 | + name: Publish to GitHub |
| 210 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 211 | + needs: |
| 212 | + - list-artifacts |
| 213 | + permissions: |
| 214 | + contents: write |
| 215 | + steps: |
| 216 | + - uses: actions/download-artifact@v6 |
| 217 | + with: |
| 218 | + name: artifacts |
| 219 | + path: dist/ |
| 220 | + - name: Get tag name |
| 221 | + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 222 | + - name: Publish to GitHub |
| 223 | + uses: softprops/action-gh-release@v2 |
| 224 | + with: |
| 225 | + draft: true |
| 226 | + files: dist/* |
| 227 | + tag_name: ${{ env.RELEASE_VERSION }} |
0 commit comments