-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (118 loc) · 4.4 KB
/
_build_linux.yml
File metadata and controls
138 lines (118 loc) · 4.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
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
name: Build Linux Wheels
on:
workflow_call:
inputs:
python-versions:
description: 'Python versions to build for'
required: false
type: string
default: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]'
jobs:
build-linux:
name: Build Linux Wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# Setup Go for BoringSSL build
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: true
# Cache vendor dependencies to speed up builds
- name: Restore vendor cache
id: cache-vendor
uses: actions/cache/restore@v4
with:
path: vendor
key: vendor-linux-manylinux-${{ hashFiles('scripts/linux/setup_vendors.sh') }}-v11
restore-keys: |
vendor-linux-manylinux-${{ hashFiles('scripts/linux/setup_vendors.sh') }}-v11
# Build wheels with cibuildwheel (handles manylinux containers)
# The vendor directory is mounted into the container and shared across Python versions
# The setup script will skip rebuilding if libraries already exist
- name: Build wheels
uses: pypa/cibuildwheel@v2.22.0
env:
# Build for specified Python versions
CIBW_BUILD: cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64 cp314-manylinux_x86_64
# Vendor build happens inside manylinux container via before-build (from pyproject.toml)
# The script will detect cached libraries and skip rebuilding
# Save vendor cache after build
- name: Save vendor cache
if: steps.cache-vendor.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: vendor
key: vendor-linux-manylinux-${{ hashFiles('scripts/linux/setup_vendors.sh') }}-v11
# Setup Python versions for testing
- name: Setup Python versions
uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
3.13
3.14
allow-prereleases: true
# Test the built wheels
- name: Test wheels
run: |
# Test each wheel that was built
for wheel in ./wheelhouse/*.whl; do
echo "========================================"
echo "Testing wheel: $(basename "$wheel")"
echo "========================================"
# Extract Python version from wheel filename (e.g., cp39, cp310)
python_tag=$(basename "$wheel" | grep -oE 'cp[0-9]+' | head -1)
python_version="${python_tag:2:1}.${python_tag:3}"
echo "Setting up Python $python_version..."
# Try to find the matching Python version
python_cmd=""
for cmd in "python${python_version}" "python3.${python_version#*.}" "python3"; do
if command -v "$cmd" &> /dev/null; then
# Verify this is the right version
version_check=$($cmd --version 2>&1 | grep -oE '[0-9]+\.[0-9]+' | head -1)
if [ "$version_check" = "$python_version" ]; then
python_cmd="$cmd"
break
fi
fi
done
# Fall back to python3 if we couldn't find exact match
if [ -z "$python_cmd" ]; then
echo "WARNING: Python $python_version not found, using python3"
python_cmd="python3"
fi
echo "Using Python: $($python_cmd --version)"
# Install the wheel in a fresh environment
"$python_cmd" -m pip install --force-reinstall "$wheel"
# Run the test script
echo ""
echo "Running tests..."
"$python_cmd" scripts/test_local_build.py
# Check exit code
if [ $? -eq 0 ]; then
echo ""
echo "[OK] Wheel test PASSED: $(basename "$wheel")"
else
echo ""
echo "[FAIL] Wheel test FAILED: $(basename "$wheel")"
exit 1
fi
echo ""
done
echo "========================================"
echo "All wheel tests PASSED"
echo "========================================"
# Upload wheels as artifacts
- uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: ./wheelhouse/*.whl
if-no-files-found: error