-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (97 loc) · 4 KB
/
Copy pathpython-publish.yml
File metadata and controls
109 lines (97 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Build and Publish
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Init submodules
run: |
git submodule update --init --recursive
# cache: pip caches the global pip wheel cache; the key is
# setup-python-<os>-pip-<hash of pyproject.toml> (auto-detected).
# This is safe for a pure download cache (unlike the old build/
# CMake cache, it contains no paths or compiled state).
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
# ── Ubuntu dependencies ──────────────────────────────────────
# patchelf is a native prerequisite of `auditwheel repair` below.
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libeigen3-dev build-essential patchelf
# ── Windows dependencies ─────────────────────────────────────
- name: Install compilation dependencies (Windows)
if: runner.os == 'Windows'
run: |
cd C:\vcpkg
.\bootstrap-vcpkg.bat
vcpkg integrate install
vcpkg install eigen3:x64-windows
cmd /c mklink /d c:\Tools\vcpkg c:\vcpkg 2>$null || true
cd ~
# ── Build ────────────────────────────────────────────────────
- name: Install build tool
run: |
python -m pip install --upgrade pip
pip install build
- name: Build wheel
run: |
python -m build --wheel
# PyPI rejects binary wheels tagged `linux_x86_64`/`linux_aarch64`
# (it requires a PEP 600 `manylinux` tag). auditwheel relinks the
# extension against system libs, bundles anything it can't, and
# retags it as `manylinux_*`.
# - --plat auto picks the tightest compatible tag from the wheel's
# actual symbols (e.g. manylinux_2_24) — hardcoding a glibc-based
# tag can fail the build. repair also fails on unsupported
# symbols, which gates the build.
# - The input glob must stay arch-scoped: a repaired
# `manylinux_2_X_<arch>.whl` still matches a bare `*linux_*.whl`
# but never `*linux_<arch>.whl`, so re-running can't pick it up.
# - repair leaves the original wheel in dist/, so the `linux_*`
# wheel is removed before upload (would be a second 400 on PyPI).
- name: Repair wheel (Linux, manylinux tag)
if: runner.os == 'Linux'
run: |
pip install auditwheel
arch=$([[ "${{ matrix.os }}" == "ubuntu-latest" ]] && echo x86_64 || echo aarch64)
auditwheel repair --plat auto -w dist/ dist/*linux_${arch}.whl
rm -f dist/*linux_${arch}.whl
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel-${{ runner.os }}-py${{ matrix.python-version }}
path: dist/
retention-days: 7
publish:
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
id-token: write
steps:
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheel-*
merge-multiple: true
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1