-
Notifications
You must be signed in to change notification settings - Fork 196
254 lines (215 loc) · 7.79 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
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 create_photonlib_pyi.py
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "photonlibpy-stubgen"
path: ./photon-lib/py/photonlibpy/lib/*.pyi
build-host:
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"
- name: "macos-12"
- name: "windows-2022"
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 --version
- run: python3 -c "from sysconfig import get_paths as gp; print(gp())"
- run: ./gradlew photon-lib:tasks -i -PpythonExecutable=python3
- run: |
chmod +x gradlew
./gradlew photon-lib:installPhotonlibpyNative -PpythonExecutable=python3
- run: find .
working-directory: ./photon-lib/py
if: matrix.os.name != 'windows-2022'
- 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: Run Unit Tests
working-directory: ./photon-lib/py
shell: powershell
run: |
pip install --no-cache-dir dist/*.whl
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
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py310
name: raspbian-aarch64-py310
build-options: "-PArchOverride=linuxarm64"
# arch: "Linuxarm64"
# - container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py311
# name: raspbian-aarch64-py311
# - container: wpilib/aarch64-cross-ubuntu:bullseye-22.04-py312
# name: raspbian-aarch64-py312
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/lib/*.pyi
- 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/