@@ -3,56 +3,151 @@ name: Build and publish Python 🐍 distributions 📦 to PyPI
33on :
44 release :
55 types : [published]
6+ pull_request :
7+ branches :
8+ - main
69 workflow_dispatch :
710
811env :
9- LSL_RELEASE_URL : " https://github.com/sccn/liblsl/releases/download/"
10- LSL_RELEASE : " 1.16.2 "
12+ LSL_RELEASE_URL : " https://github.com/sccn/liblsl/releases/download/v1.17.4 "
13+ LSL_RELEASE : " 1.17.4 "
1114
1215defaults :
1316 run :
1417 shell : bash
1518
1619jobs :
17- deploy :
18- name : ${{ matrix.config.name }}
20+ # Build pure Python wheel (no bundled library) as fallback
21+ build-pure :
22+ name : Build pure Python wheel
23+ runs-on : ubuntu-latest
24+ steps :
25+ - uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0 # Needed for setuptools-scm
28+ - name : Install uv
29+ uses : astral-sh/setup-uv@v4
30+ - name : Build pure Python wheel
31+ run : uv build
32+ - name : Upload wheels
33+ uses : actions/upload-artifact@v4
34+ with :
35+ name : wheels-pure
36+ path : dist/*
37+
38+ # Build platform-specific wheels with bundled liblsl
39+ build-platform :
40+ name : Build ${{ matrix.config.name }}
1941 runs-on : ${{ matrix.config.os }}
20- permissions :
21- id-token : write
2242 strategy :
2343 fail-fast : false
2444 matrix :
2545 config :
26- - name : " ubuntu-24.04"
27- os : " ubuntu-latest"
28- pyarch : " x64"
29- - name : " windows-x64"
30- os : " windows-latest"
31- arch : " amd64"
32- pyarch : " x64"
33- - name : " windows-x86"
34- os : " windows-latest"
35- arch : " i386"
36- pyarch : " x86"
46+ - name : " Windows x64"
47+ os : windows-latest
48+ arch : amd64
49+ pyarch : x64
50+ asset : " liblsl-${LSL_RELEASE}-Win_amd64.zip"
51+ extract : " unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
52+ - name : " Windows x86"
53+ os : windows-latest
54+ arch : i386
55+ pyarch : x86
56+ asset : " liblsl-${LSL_RELEASE}-Win_i386.zip"
57+ extract : " unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
58+ - name : " macOS universal"
59+ os : macos-latest
60+ arch : universal
61+ pyarch : x64
62+ asset : " lsl.xcframework.1.17.zip"
63+ extract : |
64+ unzip xcframework.zip
65+ cp lsl.xcframework/macos-arm64_x86_64/lsl.framework/Versions/A/lsl src/pylsl/lib/liblsl.dylib
66+ codesign -s - -f src/pylsl/lib/liblsl.dylib
67+ - name : " Linux x86_64"
68+ os : ubuntu-22.04
69+ arch : x86_64
70+ pyarch : x64
71+ asset : " liblsl-${LSL_RELEASE}-jammy_amd64.deb"
72+ extract : |
73+ sudo apt-get update && sudo apt-get install -y libpugixml1v5
74+ ar x liblsl.deb
75+ tar -xf data.tar.* --wildcards '*/liblsl.so*'
76+ cp ./usr/lib/liblsl.so* src/pylsl/lib/
77+ repair : true
3778 steps :
3879 - uses : actions/checkout@v4
39- - name : Download liblsl (Windows)
40- if : matrix.config.os == 'windows-latest'
80+ with :
81+ fetch-depth : 0 # Needed for setuptools-scm
82+
83+ - name : Download liblsl
84+ run : |
85+ ASSET="${{ matrix.config.asset }}"
86+ ASSET="${ASSET//\$\{LSL_RELEASE\}/$LSL_RELEASE}"
87+ if [[ "$ASSET" == *xcframework* ]]; then
88+ curl -L "${LSL_RELEASE_URL}/${ASSET}" -o xcframework.zip
89+ elif [[ "$ASSET" == *.zip ]]; then
90+ curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.zip
91+ elif [[ "$ASSET" == *.deb ]]; then
92+ curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.deb
93+ else
94+ curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.tar.gz
95+ fi
96+
97+ - name : Extract liblsl
4198 run : |
42- curl -L ${LSL_RELEASE_URL}/v${LSL_RELEASE}/liblsl-${LSL_RELEASE}-Win_${{ matrix.config.arch}}.zip -o liblsl.zip
43- unzip -oj liblsl.zip bin/lsl* -d src/pylsl/lib
44- - name : Set up Python 3.x
45- uses : actions/setup-python@v4
99+ mkdir -p src/pylsl/lib
100+ ${{ matrix.config.extract }}
101+
102+ - name : List bundled library
103+ run : ls -la src/pylsl/lib/
104+
105+ - name : Set up Python
106+ uses : actions/setup-python@v5
46107 with :
47108 python-version : " 3.x"
48109 architecture : ${{ matrix.config.pyarch }}
110+
49111 - name : Install uv
50112 uses : astral-sh/setup-uv@v4
51- - name : Build Package (Linux)
52- if : matrix.config.os != 'windows-latest'
53- run : uv build
54- - name : Build Package (Windows)
55- if : matrix.config.os == 'windows-latest'
113+
114+ - name : Build wheel
56115 run : uv build --wheel
57- - name : Publish package distributions to PyPI
58- run : uv publish
116+
117+ - name : Repair wheel (Linux)
118+ if : matrix.config.repair
119+ run : |
120+ pip install auditwheel patchelf
121+ auditwheel repair dist/*.whl -w dist/
122+ rm dist/*-none-any.whl
123+
124+ - name : Upload wheels
125+ uses : actions/upload-artifact@v4
126+ with :
127+ name : wheels-${{ matrix.config.os }}-${{ matrix.config.arch }}
128+ path : dist/*.whl
129+
130+ # Publish all wheels to PyPI
131+ publish :
132+ name : Publish to PyPI
133+ needs : [build-pure, build-platform]
134+ runs-on : ubuntu-latest
135+ permissions :
136+ id-token : write
137+ steps :
138+ - name : Download all wheels
139+ uses : actions/download-artifact@v4
140+ with :
141+ path : dist
142+ pattern : wheels-*
143+ merge-multiple : true
144+
145+ - name : List wheels
146+ run : ls -la dist/
147+
148+ - name : Install uv
149+ uses : astral-sh/setup-uv@v4
150+
151+ - name : Publish to PyPI
152+ if : github.event_name == 'release'
153+ run : uv publish dist/*
0 commit comments