|
| 1 | +# Build & publish `dlslime` and `dlslime-ctrl` wheels to PyPI on tag push. |
| 2 | +# |
| 3 | +# Auth: PyPI Trusted Publishing via OIDC — no secrets needed. |
| 4 | +# See RELEASING.md for the one-time PyPI configuration. |
| 5 | +# |
| 6 | +# Triggered by `vX.Y.Z` tags (e.g. as produced by scripts/release.sh). |
| 7 | + |
| 8 | +name: pypi-publish |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + tags: ["v*"] |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + dry_run: |
| 16 | + description: "Build wheels but skip the upload step" |
| 17 | + type: boolean |
| 18 | + default: false |
| 19 | + |
| 20 | +permissions: |
| 21 | + id-token: write # required for OIDC token exchange with PyPI |
| 22 | + contents: read |
| 23 | + |
| 24 | +jobs: |
| 25 | + # ---------------- dlslime (Python + C++ via scikit-build-core) ----------------- |
| 26 | + build-dlslime-sdist: |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v6 |
| 30 | + - uses: actions/setup-python@v6 |
| 31 | + with: |
| 32 | + python-version: "3.12" |
| 33 | + - run: python -m pip install build |
| 34 | + - run: python -m build --sdist --outdir dist dlslime |
| 35 | + - uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: dist-dlslime-sdist |
| 38 | + path: dist/*.tar.gz |
| 39 | + |
| 40 | + build-dlslime-wheels: |
| 41 | + runs-on: ubuntu-24.04 |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + python: ["cp310", "cp311", "cp312", "cp313"] |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v6 |
| 48 | + - uses: pypa/cibuildwheel@v3.4 |
| 49 | + env: |
| 50 | + # Build only the matching Python ABI on x86_64 manylinux. |
| 51 | + CIBW_BUILD: "${{ matrix.python }}-manylinux_x86_64" |
| 52 | + CIBW_BEFORE_ALL_LINUX: | |
| 53 | + yum install -y libibverbs-devel numactl-devel || \ |
| 54 | + (apt-get update && apt-get install -y libibverbs-dev libnuma-dev) |
| 55 | + CIBW_ENVIRONMENT: >- |
| 56 | + CMAKE_ARGS=-DBUILD_RDMA=ON -DBUILD_PYTHON=ON |
| 57 | + -DBUILD_NVLINK=OFF -DBUILD_TORCH_PLUGIN=OFF |
| 58 | + -DBUILD_ASCEND_DIRECT=OFF -DBUILD_TEST=OFF |
| 59 | + # Don't try to bundle libibverbs / libnuma into the wheel: |
| 60 | + # they're system-level libraries (provided by the rdma-core / numactl |
| 61 | + # packages on the user's host) and are NOT in the manylinux policy |
| 62 | + # whitelist, so auditwheel would otherwise fail with |
| 63 | + # `auditwheel repair ... failed with code 1`. |
| 64 | + # auditwheel must skip two classes of libraries: |
| 65 | + # 1. System RDMA / NUMA stack — provided by the user's rdma-core |
| 66 | + # install, NOT in the manylinux policy allowlist, must not be |
| 67 | + # vendored or wheels would conflict with host kernel modules. |
| 68 | + # 2. DLSlime's own sibling shared libs (lib_slime_rdma.so, |
| 69 | + # lib_slime_obs.so) — they're already installed next to |
| 70 | + # _slime_c.so inside the wheel and resolved at runtime via the |
| 71 | + # $ORIGIN rpath baked in by CMake. auditwheel doesn't know how to |
| 72 | + # look "inside the wheel" so we tell it to leave them alone. |
| 73 | + CIBW_REPAIR_WHEEL_COMMAND_LINUX: >- |
| 74 | + auditwheel repair |
| 75 | + --exclude libibverbs.so.1 |
| 76 | + --exclude libnuma.so.1 |
| 77 | + --exclude libmlx5.so.1 |
| 78 | + --exclude libmlx4.so.1 |
| 79 | + --exclude librdmacm.so.1 |
| 80 | + --exclude libibumad.so.3 |
| 81 | + --exclude libefa.so.1 |
| 82 | + --exclude lib_slime_topology.so |
| 83 | + --exclude lib_slime_engine.so |
| 84 | + --exclude lib_slime_device.so |
| 85 | + --exclude lib_slime_obs.so |
| 86 | + --exclude lib_slime_rdma.so |
| 87 | + --exclude lib_slime_nvlink.so |
| 88 | + --exclude libascend_direct.so |
| 89 | + -w {dest_dir} {wheel} |
| 90 | + with: |
| 91 | + package-dir: dlslime |
| 92 | + output-dir: dist |
| 93 | + - uses: actions/upload-artifact@v4 |
| 94 | + with: |
| 95 | + name: dist-dlslime-${{ matrix.python }} |
| 96 | + path: dist/*.whl |
| 97 | + |
| 98 | + # ---------------- dlslime-ctrl (Rust bin wheel via maturin) -------------------- |
| 99 | + build-dlslime-ctrl: |
| 100 | + runs-on: ubuntu-24.04 |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v6 |
| 103 | + - uses: actions/setup-python@v6 |
| 104 | + with: |
| 105 | + python-version: "3.12" |
| 106 | + - uses: dtolnay/rust-toolchain@stable |
| 107 | + - run: python -m pip install "maturin>=1.0,<2.0" |
| 108 | + - run: maturin build --release --out dist --manifest-path dlslime-ctrl/Cargo.toml |
| 109 | + - uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: dist-dlslime-ctrl |
| 112 | + path: dist/*.whl |
| 113 | + |
| 114 | + # ---------------- Publish to PyPI (Trusted Publishing) ------------------------- |
| 115 | + publish-dlslime: |
| 116 | + needs: [build-dlslime-sdist, build-dlslime-wheels] |
| 117 | + if: ${{ github.event_name == 'push' || !inputs.dry_run }} |
| 118 | + runs-on: ubuntu-24.04 |
| 119 | + environment: pypi # add manual-approval gate via repo Settings → Environments |
| 120 | + steps: |
| 121 | + - uses: actions/download-artifact@v4 |
| 122 | + with: |
| 123 | + pattern: dist-dlslime-* |
| 124 | + path: dist |
| 125 | + merge-multiple: true |
| 126 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 127 | + with: |
| 128 | + packages-dir: dist |
| 129 | + # No `password:` — OIDC handles auth. |
| 130 | + |
| 131 | + publish-dlslime-ctrl: |
| 132 | + needs: [build-dlslime-ctrl] |
| 133 | + if: ${{ github.event_name == 'push' || !inputs.dry_run }} |
| 134 | + runs-on: ubuntu-24.04 |
| 135 | + environment: pypi |
| 136 | + steps: |
| 137 | + - uses: actions/download-artifact@v4 |
| 138 | + with: |
| 139 | + name: dist-dlslime-ctrl |
| 140 | + path: dist |
| 141 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 142 | + with: |
| 143 | + packages-dir: dist |
0 commit comments