-
Notifications
You must be signed in to change notification settings - Fork 804
175 lines (157 loc) · 6.06 KB
/
build-cibw.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
# This workflow builds the Python wheels using cibuildwheel and uploads them to TestPyPI.
# It can be triggered on push to the develop branch or manually via Github Actions.
name: Build Wheels (cibuildwheel)
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
# Get the system time and store it in an output. This is used to tag the wheels.
# This needs to be done in a separate job so that each matrix job in build_wheels can
# access the same timestamp.
get_system_time:
name: Get System Time
runs-on: ubuntu-latest
outputs:
timestamp: ${{ steps.get_time.outputs.timestamp }}
steps:
- name: Get system time
id: get_time
run: echo "timestamp=$(date +'%Y%m%d%H%M')" >> "$GITHUB_OUTPUT"
build_wheels:
name: Build Wheels
needs: get_system_time
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- os: ubuntu-latest
python_version: "3.10"
cibw_python_version: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python_version: "3.11"
cibw_python_version: 311
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python_version: "3.12"
cibw_python_version: 312
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python_version: "3.13"
cibw_python_version: 313
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
# Linux aarch64
- os: ubuntu-24.04-arm
python_version: "3.10"
cibw_python_version: 310
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
- os: ubuntu-24.04-arm
python_version: "3.11"
cibw_python_version: 311
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
- os: ubuntu-24.04-arm
python_version: "3.12"
cibw_python_version: 312
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
- os: ubuntu-24.04-arm
python_version: "3.13"
cibw_python_version: 313
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
# MacOS x86_64
# - os: macos-13
# python_version: "3.10"
# cibw_python_version: 310
# platform_id: macosx_x86_64
# - os: macos-13
# python_version: "3.11"
# cibw_python_version: 311
# platform_id: macosx_x86_64
# - os: macos-13
# python_version: "3.12"
# cibw_python_version: 312
# platform_id: macosx_x86_64
# - os: macos-13
# python_version: "3.13"
# cibw_python_version: 313
# platform_id: macosx_x86_64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
# Set the DEVELOP flag and the TIMESTAMP environment variables. This is used in the
# top-level CMakeLists.txt to generate the GTSAM_VERSION_STRING.
- name: Set Develop Flag
run: |
echo "DEVELOP=1" >> $GITHUB_ENV
echo "TIMESTAMP=${{ needs.get_system_time.outputs.timestamp }}" >> $GITHUB_ENV
- name: Install Dependencies
run: |
python3 -m pip install -r python/dev_requirements.txt
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get install -y wget libicu-dev python3-pip python3-setuptools libboost-all-dev ninja-build
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install wget icu4c boost ninja python-setuptools
else
echo "$RUNNER_OS not supported"
exit 1
fi
# We first build the Python wrapper module on the host machine. This is done because cibuildwheel
# expects a setup.py file to be present in the project directory.
#
# The Python wrapper module is then rebuilt within the cibuildwheel container before building
# the wheels to ensure platform compatibility.
- name: Run CMake
run: |
cmake . -B build -DGTSAM_BUILD_PYTHON=1 -DGTSAM_PYTHON_VERSION=${{ matrix.python_version }}
- name: Build and test wheels
env:
# Generate the platform identifier. See https://cibuildwheel.pypa.io/en/stable/options/#build-skip.
CIBW_BUILD: cp${{ matrix.cibw_python_version }}-${{ matrix.platform_id }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_ARCHS: all
CIBW_ENVIRONMENT_PASS_LINUX: DEVELOP TIMESTAMP
# Use build instead of pip wheel to build the wheels. This is recommended by PyPA.
# See https://cibuildwheel.pypa.io/en/stable/options/#build-frontend.
CIBW_BUILD_FRONTEND: "build"
CIBW_BEFORE_ALL: bash {project}/build_tools/wheels/cibw_before_all.sh ${{ matrix.python_version }} {project}
CIBW_BUILD_VERBOSITY: 1
run: bash build_tools/wheels/build_wheels.sh
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-cp${{ matrix.cibw_python_version }}-${{ matrix.platform_id }}
path: wheelhouse/*.whl
upload_all:
name: Upload All
needs: build_wheels
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
packages-dir: dist/
# repository-url: https://test.pypi.org/legacy/