-
Notifications
You must be signed in to change notification settings - Fork 74
200 lines (193 loc) · 6.81 KB
/
build-wheels-and-deploy.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
name: Build wheels and deploy
on:
# this workflow can only be manually triggered for now.
workflow_dispatch:
inputs:
deploy:
description: 'Where to deploy the artifacts? Only build (build), deploy to test PyPI (test), or deploy to PyPI (prod).'
required: true
type: choice
default: 'build'
options:
- build
- test
- prod
jobs:
build-stubs:
name: Build Python stubs
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Upgrade pip and python packages
run: |
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel==2.17.0 pybind11-stubgen==1.1
- name: Install dependencies
shell: bash
run: |
# Update & upgrade package lists
sudo apt-get update -y
sudo apt-get upgrade
# Deal with Github CI limitation
# https://github.com/actions/runner-images/issues/6399#issuecomment-1285011525
sudo apt install -y libunwind-dev
# Generic dependencies
sudo apt-get install cmake libopenblas-dev
# Install VRS dependencies
sudo apt-get install -o Acquire::Retries=5 \
libgtest-dev libgmock-dev \
libfmt-dev \
libturbojpeg-dev libpng-dev \
liblz4-dev libzstd-dev libxxhash-dev \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-iostreams-dev \
libboost-system-dev
# Clean APT cache
sudo apt-get clean
- name: Install projectaria_tools
run: |
# Build and install Python bindings (required to run the stubs on the pybind artifacts)
CMAKE_BUILD_PARALLEL_LEVEL=4 pip3 install .
rm -rf build
- name: Generate stubs & Include stubs in python package
run: |
python3 generate_stubs.py
cp -r projectaria_tools-stubs/projectaria_tools .
- uses: actions/upload-artifact@v4
with:
name: projectaria_tools_stubs
path: projectaria_tools
build-wheels:
name: Build wheels ${{ matrix.os }} | ${{ matrix.python-version }}
needs:
- build-stubs
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, ubuntu-22.04, macos-latest-xlarge, windows-2022]
python-version: ["3.10", "3.11", "3.12"]
# Default consider only Python >=3.10 since actions/setup-python supports only python<3.10 and mac-silicon
# Other Python versions are added below as matrix entries
include: # Customize cibuildwheel python version to build
- python-version: "3.10"
cibw_build: "cp310-*"
- python-version: "3.11"
cibw_build: "cp311-*"
- python-version: "3.12"
cibw_build: "cp312-*"
# Add matrix entries: Python ["3.8", "3.9"] to [macos-13, ubuntu-latest]
- os: ubuntu-22.04
python-version: "3.8"
cibw_build: "cp38-*"
- os: ubuntu-22.04
python-version: "3.9"
cibw_build: "cp39-*"
- os: macos-13
python-version: "3.8"
cibw_build: "cp38-*"
- os: macos-13
python-version: "3.9"
cibw_build: "cp39-*"
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download the pre-computed python stubs
uses: actions/download-artifact@v4
with:
name: projectaria_tools_stubs
path: projectaria_tools
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and python packages
run: |
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel==2.17.0
- name: Build wheels for CPython
if: matrix.os == 'macos-latest-xlarge'
shell: bash
run: |
CMAKE_BUILD_PARALLEL_LEVEL=4 python3 -m cibuildwheel --output-dir dist
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*-manylinux_i686 *-musllinux_* *x86_64*"
CIBW_ARCHS: "arm64"
- name: Build wheels for CPython
if: ${{ (matrix.os == 'macos-13') || (matrix.os == 'ubuntu-22.04') }}
shell: bash
run: |
CMAKE_BUILD_PARALLEL_LEVEL=4 python3 -m cibuildwheel --output-dir dist
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
CIBW_ARCHS: "x86_64"
- name: Build wheels for CPython
if: matrix.os == 'windows-2022'
shell: bash
run: |
python3 -m cibuildwheel --output-dir dist
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*-manylinux_i686 *-musllinux_* *-win32"
CIBW_ARCHS: "AMD64"
CIBW_PLATFORM: "windows"
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.os }}-${{ matrix.python-version }}
path: dist
- name: Test wheel
shell: bash
run: |
# Install wheel
python3 -m pip install dist/*.whl
# Run Python unit tests
export TEST_FOLDER="./data/"
python3 -m unittest core/python/test/corePyBindTest.py
python3 -m unittest core/python/test/mpsPyBindTest.py
publish-to-pypi:
name: Publish to Pypi
runs-on: ubuntu-latest
needs:
- build-wheels
steps:
- name: Download wheels from previous jobs
# by default this will download all artifacts
uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
merge-multiple: true
# PyPI publish action uploads everything under dist/* by default
path: dist
- name: Display the list of artifacts
run: ls -R dist
- name: Publish to Test PyPI
if: github.event.inputs.deploy == 'test'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN_PROJECTARIA_TOOLS }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
verbose: true
- name: Publish to PyPI
if: github.event.inputs.deploy == 'prod'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN_PROJECTARIA_TOOLS_DEV }}
skip_existing: true
verbose: true