-
Notifications
You must be signed in to change notification settings - Fork 201
295 lines (252 loc) · 9.47 KB
/
python.yml
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Build and Distribute PhotonLibPy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
on:
push:
branches: [ master ]
tags:
- 'v*'
paths:
- '**'
- '!docs/**'
- '.github/**'
pull_request:
branches: [ master ]
paths:
- '**'
- '!docs/**'
- '.github/**'
jobs:
build-pyi:
runs-on: "ubuntu-22.04"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v5
with:
# Lowest version supported so typing information is always valid
python-version: 3.9
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- run: git fetch --tags --force
- run: python3 -c "from sysconfig import get_paths as gp; print(gp())"
- run: |
chmod +x gradlew
./gradlew photon-lib:installPhotonlibpyNative -PpythonExecutable=python3.9
- name: Install dependencies
working-directory: ./photon-lib/py
run: |
python -m pip install --upgrade pip
python -m pip install -r build_requirements.txt
- name: Build wheel
working-directory: ./photon-lib/py
# Now that we have native .so's in place, generate pyi
run: |
python -m build -swn
python -m pip install --no-cache-dir dist/*.whl
python create_photonlib_pyi.py
- name: Build photonlibpy api docs
working-directory: ./photon-lib/py/docs
# Now that we have native .so's in place, generate pyi
run: |
pip install -r ../../../docs/requirements.txt
make html
- run: find photon-lib/py
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "photonlibpy-stubgen"
path: ./photon-lib/py/photonlibpy/**/*.pyi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "photonlibpy-apidocs"
path: ./photon-lib/py/docs/build/html
build-host:
env:
MACOSX_DEPLOYMENT_TARGET: 13
strategy:
# max-parallel: 1
fail-fast: false
matrix:
# Reference: https://github.com/wpilibsuite/wpilib-tool-plugin/blob/main/src/main/java/edu/wpi/first/tools/NativePlatforms.java#L23
os:
- name: "ubuntu-22.04"
extra_args: "-PnativeBuildPlatform=Linuxx86-64"
- name: "macos-14"
extra_args: "-PnativeBuildPlatform=Osxuniversal -PnativeBuildFolder=osxuniversal"
- name: "windows-latest"
extra_args: "-PnativeBuildPlatform=Windowsx86-64"
python_version:
# - '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
runs-on: ${{ matrix.os.name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- run: git fetch --tags --force
- run: python3 -c "from sysconfig import get_paths as gp; print(gp())"
- if: ${{ !startsWith(matrix.os.name, 'windows') }}
run: |
find $(python3 -c "from sysconfig import get_paths as gp; print(gp()['stdlib'])")
find $(python3 -c "from sysconfig import get_paths as gp; print(gp()['data'])")
- run: ./gradlew photon-lib:tasks -i -PpythonExecutable=python3
- run: |
chmod +x gradlew
./gradlew photon-lib:installPhotonlibpyNative -PpythonExecutable=python3 ${{ matrix.os.extra_args }}
- name: Install dependencies
working-directory: ./photon-lib/py
run: |
python -m pip install --upgrade pip
python -m pip install -r build_requirements.txt
- name: Build wheel
working-directory: ./photon-lib/py
# disable isolation so we can run stubgen (ew but w/e)
run: |
python -m build -swn
- name: Upload everything
uses: actions/upload-artifact@v4
if: ${{ startsWith(matrix.os.name, 'windows') }}
with:
name: "debug-build-${{ runner.os }}-${{ matrix.python_version }}"
path: ./photon-lib/
- name: Run Unit Tests
working-directory: ./photon-lib/py
if: ${{ !startsWith(matrix.os.name, 'windows') }}
run: |
python -m pip install --no-cache-dir dist/*.whl
python -m pytest
- name: Run Unit Tests
working-directory: ./photon-lib/py
if: ${{ startsWith(matrix.os.name, 'windows') }}
run: |
pip install --no-cache-dir (Get-ChildItem -Path dist\*.whl).FullName
python -m pytest
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "dist-${{ runner.os }}-${{ matrix.python_version }}"
path: ./photon-lib/py/dist/
# - name: Publish package distributions to TestPyPI
# # Only upload on tags
# if: startsWith(github.ref, 'refs/tags/v')
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages_dir: ./photon-lib/py/dist/
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
cross-build:
runs-on: ubuntu-latest
needs: build-pyi
strategy:
# max-parallel: 1
fail-fast: false
matrix:
os:
- container: wpilib/roborio-cross-ubuntu:2024-22.04-py312
name: roborio
build-options: "-PArchOverride=linuxathena"
# gradle needs first letter uppercase
arch: "Linuxathena"
# - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04-py38
# name: raspbian-py38
# - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04-py39
# name: raspbian-py39
# - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04-py310
# name: raspbian-py310
# - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04-py311
# name: raspbian-py311
# - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04-py312
# name: raspbian-py312
# - container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py38
# name: raspbian-aarch64-py38
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py39
name: raspbian-aarch64-py39
arch: "Linuxarm64"
build-options: "-PArchOverride=linuxarm64"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py310
name: raspbian-aarch64-py310
arch: "Linuxarm64"
build-options: "-PArchOverride=linuxarm64"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py311
name: raspbian-aarch64-py311
arch: "Linuxarm64"
build-options: "-PArchOverride=linuxarm64"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py312
name: raspbian-aarch64-py312
arch: "Linuxarm64"
build-options: "-PArchOverride=linuxarm64"
container:
image: "${{ matrix.os.container }}"
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Install setuptools + wheel
run: |
/build/venv/bin/build-pip --disable-pip-version-check install -U "setuptools==63.4.3; python_version < '3.12'"
/build/venv/bin/build-pip --disable-pip-version-check install -U wheel==0.41.2
/build/venv/bin/cross-pip --disable-pip-version-check install -U "setuptools==63.4.3; python_version < '3.12'"
/build/venv/bin/cross-pip --disable-pip-version-check install -U wheel==0.41.2
# See https://github.com/pypa/setuptools_scm/issues/784
- name: Set git directory as safe to allow setuptools-scm to work
shell: bash
run: |
pwd
/usr/bin/git config --global --add safe.directory $(pwd)
- name: Install deps
shell: bash
run: |
/build/venv/bin/cross-pip --disable-pip-version-check install -r photon-lib/py/build_requirements.txt
- run: git fetch --tags --force
- run: ./gradlew photon-lib:tasks -PpythonExecutable=/build/venv/bin/cross-python
- name: Install RoboRIO Toolchain
run: ./gradlew installRoboRioToolchain -PpythonExecutable=/build/venv/bin/cross-python
if: matrix.os.name == 'roborio'
- run: ./gradlew photon-lib:tasks -PpythonExecutable=/build/venv/bin/cross-python
- run: |
chmod +x gradlew
./gradlew photon-lib:installPhotonlibpyNative -PpythonExecutable=/build/venv/bin/cross-python ${{ matrix.os.build-options }}
# Download our type hints
- uses: actions/download-artifact@v4
with:
name: "photonlibpy-stubgen"
path: ./photon-lib/py/photonlibpy/
- name: Build wheel
working-directory: ./photon-lib/py
# disable isolation so we can run stubgen (ew but w/e)
run: |
SKIP_PYI=1 /build/venv/bin/cross-python -m build -swn
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "dist-${{ matrix.os.name }}"
path: ./photon-lib/py/dist/