Repository navigation
151 lines (135 loc) · 5.35 KB
/
Copy pathpython.yml
File metadata and controls
151 lines (135 loc) · 5.35 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Python
on:
push:
branches: [main]
pull_request:
paths:
- '.github/workflows/python.yml'
- 'cmake/**'
- 'python/src/**'
- 'python/CMakeLists.txt'
- 'python/src/CMakeLists.txt'
- 'src/**'
- 'CMakeLists.txt'
- 'pyproject.toml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
Python-Versions:
runs-on: ubuntu-latest
outputs:
all: ${{ steps.matrix.outputs.all }}
pr: ${{ steps.matrix.outputs.pr }}
steps:
- name: Compute supported Python versions
id: matrix
env:
MIN_MINOR: 11 # our own floor; raise it manually if we ever need to
run: |
today=$(date +%F)
all=$(curl -fsS https://endoflife.date/api/python.json | jq -c \
--arg today "$today" --argjson min "$MIN_MINOR" '
[ .[]
| select(.cycle | startswith("3."))
| select((.cycle | split(".")[1] | tonumber) >= $min)
| select(.releaseDate <= $today) # already released
| select(.eol > $today) # not yet EOL
| .cycle ]
| sort_by(split(".")[1] | tonumber)')
# PRs: second-newest release (currently 3.14), so we don't
# chase brand-new wheels on every PR
pr=$(jq -c '[.[-2]]' <<< "$all")
echo "all=$all" >> "$GITHUB_OUTPUT"
echo "pr=$pr" >> "$GITHUB_OUTPUT"
Build:
needs: Python-Versions
name: ${{ matrix.name }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ${{ github.event_name == 'pull_request' && fromJSON(needs.Python-Versions.outputs.pr) || fromJSON(needs.Python-Versions.outputs.all) }}
include:
- os: ubuntu-latest
name: Linux
- os: windows-latest
name: Windows
- os: macOS-latest
name: macOS
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
fetch-depth: 10
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install Ccache (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install ccache
echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV"
- name: Install Ccache (macOS)
if: runner.os == 'macOS'
run: |
brew install ccache
echo 'CACHE_PATH=~/Library/Caches/ccache' >> "$GITHUB_ENV"
- name: Install Ccache (Windows)
if: runner.os == 'Windows'
run: |
choco install ccache
"CACHE_PATH=${env:LOCALAPPDATA}\ccache" | Out-File -FilePath $env:GITHUB_ENV -Append
# scikit-build-core picks the Visual Studio generator on Windows. That
# generator ignores CMAKE_<LANG>_COMPILER_LAUNCHER, so ccache never runs,
# and it compiles the files of each target one at a time. We use Ninja
# instead, which needs the MSVC environment set up first.
- name: Setup MSVC (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Use Ninja (Windows)
if: runner.os == 'Windows'
run: |
"CMAKE_GENERATOR=Ninja" | Out-File -FilePath $env:GITHUB_ENV -Append
# On Linux, explicitly build for x86-64-v3 instead of -march=native. This
# avoids issues with ccache restoring from a runner with a different ISA.
- name: Check x86-64-v3 support (Linux)
if: runner.os == 'Linux'
run: |
for f in avx2 bmi1 bmi2 f16c fma abm movbe xsave; do
grep -qw "$f" /proc/cpuinfo || { echo "::error::Runner CPU lacks $f, which x86-64-v3 requires"; exit 1; }
done
echo "CPU: $(grep -m1 '^model name' /proc/cpuinfo | cut -d: -f2-)"
# Cache entries are immutable, so a fixed key is saved once and never
# updated. We give each run its own key and restore the newest one by
# prefix instead. Only pushes to main save, and PRs restore from those.
- name: Restore ccache
uses: actions/cache/restore@v5
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-Python${{ matrix.python-version }}-ccache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-Python${{ matrix.python-version }}-ccache-
- name: Prepare Ccache
run: |
ccache --max-size=1.0G
ccache -V && ccache --show-config
ccache --show-stats && ccache --zero-stats
- name: Build and Install
env:
CMAKE_ARGS: ${{ runner.os == 'Linux' && '-DSIMD_CXX_FLAGS=-march=x86-64-v3' || '' }}
run: |
pip install --verbose . && ccache --show-stats
- name: Save ccache
if: ${{ !cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v5
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-Python${{ matrix.python-version }}-ccache-${{ github.run_id }}
- name: Tests
run: |
pip install -r python/tests/requirements.txt
nose2 -v --pretty-assert -s python/tests