-
Notifications
You must be signed in to change notification settings - Fork 64
172 lines (152 loc) · 5.08 KB
/
Copy pathpublish-to-pypi.yml
File metadata and controls
172 lines (152 loc) · 5.08 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Build and publish Python 🐍 distributions 📦 to PyPI
on:
release:
types: [published]
pull_request:
branches:
- main
workflow_dispatch:
env:
LSL_RELEASE_URL: "https://github.com/sccn/liblsl/releases/download/v1.17.7"
LSL_RELEASE: "1.17.7"
defaults:
run:
shell: bash
jobs:
# Build pure Python wheel (no bundled library) as fallback
build-pure:
name: Build pure Python wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools-scm
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build pure Python wheel
run: uv build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-pure
path: dist/*
# Build platform-specific wheels with bundled liblsl
build-platform:
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "Windows x64"
os: windows-latest
arch: amd64
pyarch: x64
asset: "liblsl-${LSL_RELEASE}-Win_amd64.zip"
extract: "unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
platform_tag: "win_amd64"
- name: "Windows x86"
os: windows-latest
arch: i386
pyarch: x86
asset: "liblsl-${LSL_RELEASE}-Win_i386.zip"
extract: "unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
platform_tag: "win32"
- name: "macOS universal"
os: macos-latest
arch: universal
pyarch: x64
asset: "lsl.xcframework.1.17.zip"
extract: |
unzip xcframework.zip
cp lsl.xcframework/macos-arm64_x86_64/lsl.framework/Versions/A/lsl src/pylsl/lib/liblsl.dylib
codesign -s - -f src/pylsl/lib/liblsl.dylib
platform_tag: "macosx_11_0_universal2"
- name: "Linux x86_64"
os: ubuntu-22.04
arch: x86_64
pyarch: x64
asset: "liblsl-${LSL_RELEASE}-jammy_amd64.deb"
extract: |
sudo apt-get update && sudo apt-get install -y libpugixml1v5
ar x liblsl.deb
tar -xf data.tar.* --wildcards '*/liblsl.so*'
cp ./usr/lib/liblsl.so* src/pylsl/lib/
repair: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools-scm
- name: Download liblsl
run: |
ASSET="${{ matrix.config.asset }}"
ASSET="${ASSET//\$\{LSL_RELEASE\}/$LSL_RELEASE}"
if [[ "$ASSET" == *xcframework* ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o xcframework.zip
elif [[ "$ASSET" == *.zip ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.zip
elif [[ "$ASSET" == *.deb ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.deb
else
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.tar.gz
fi
- name: Extract liblsl
run: |
mkdir -p src/pylsl/lib
${{ matrix.config.extract }}
- name: List bundled library
run: ls -la src/pylsl/lib/
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
architecture: ${{ matrix.config.pyarch }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build wheel
run: uv build --wheel
- name: Tag wheel with platform
if: matrix.config.platform_tag
run: |
pip install wheel
wheel tags --platform-tag ${{ matrix.config.platform_tag }} dist/*.whl
rm -f dist/*-none-any.whl
ls -la dist/
- name: Inspect wheel contents
run: |
python -m zipfile -l dist/*.whl | grep -E '\.(dll|so|dylib)' || echo "No native libraries found in wheel!"
- name: Repair wheel (Linux)
if: matrix.config.repair
run: |
pip install auditwheel patchelf
auditwheel repair dist/*.whl -w dist/
rm dist/*-none-any.whl
- name: Test wheel
run: |
pip install dist/*.whl
python -c "import pylsl; print(pylsl.library_info())"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.config.os }}-${{ matrix.config.arch }}
path: dist/*.whl
# Publish all wheels to PyPI
publish:
name: Publish to PyPI
needs: [build-pure, build-platform]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: dist
pattern: wheels-*
merge-multiple: true
- name: List wheels
run: ls -la dist/
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Publish to PyPI
run: uv publish dist/* ${{ github.event_name != 'release' && '--dry-run -v' || '' }}