-
Notifications
You must be signed in to change notification settings - Fork 2
224 lines (195 loc) · 7.02 KB
/
build_pymeos_cffi.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
name: Build PyMEOS CFFI
on:
create:
tags:
- "pymeos-cffi-[0-9]+.[0-9]+.[0-9]+*"
jobs:
build_sdist:
name: Build PyMEOS CFFI source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
- name: Setup pip
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist
working-directory: pymeos_cffi
run: |
python -m build -s
ls -l dist
- uses: actions/upload-artifact@v4
with:
name: pymeos_cffi-sdist
path: ./pymeos_cffi/dist/pymeos_cffi-*.tar.gz
build_wheels:
name: Build PyMEOS CFFI for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-13, macos-14 ]
include:
- ld_prefix: "/usr/local"
- os: macos-14
ld_prefix: "/opt/homebrew"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update brew
if: matrix.os == 'macos-13'
# Necessary to avoid issue with macOS runners. See
# https://github.com/actions/runner-images/issues/4020
run: |
brew reinstall [email protected] || brew link --overwrite [email protected]
brew reinstall [email protected] || brew link --overwrite [email protected]
brew update
- name: Get dependencies from homebrew (cache)
uses: tecolicom/actions-use-homebrew-tools@v1
if: runner.os == 'macOS'
with:
tools: cmake libpq proj json-c gsl geos
- name: Get PROJ version
id: proj_version
if: runner.os == 'macOS'
run: |
proj_version=$(brew list --versions proj)
proj_version=${proj_version#* }
echo "proj_version=$proj_version" >> $GITHUB_OUTPUT
- name: Install MEOS
if: runner.os == 'macOS'
run: |
git clone --depth 1 https://github.com/MobilityDB/MobilityDB
mkdir MobilityDB/build
cd MobilityDB/build
cmake .. -DMEOS=on
make -j
sudo make install
- name: Setup Python
uses: actions/setup-python@v5
with:
cache: "pip"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.17.0
- name: Set PROJ_DATA (macOS)
if: runner.os == 'macOS'
run: |
PROJ_DATA=${{ matrix.ld_prefix }}/Cellar/proj/${{ steps.proj_version.outputs.proj_version }}/share/proj
echo "PROJ_DATA=$PROJ_DATA" >> $GITHUB_ENV
- name: Set PROJ_DATA and JSON-C path (Linux)
if: runner.os == 'Linux'
run: |
PROJ_DATA=/usr/proj81/share/proj
echo "PROJ_DATA=$PROJ_DATA" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64" >> $GITHUB_ENV
- name: Build wheels
working-directory: pymeos_cffi
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
export PACKAGE_DATA=1
python -m cibuildwheel --output-dir wheelhouse
env:
# Disable PyPy builds
# Disable builds on musllinux
# Disable builds in linux architectures other than x86_64
CIBW_SKIP: "pp* *musllinux*"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ENVIRONMENT_PASS_LINUX: PACKAGE_DATA LD_LIBRARY_PATH PROJ_DATA
CIBW_BEFORE_ALL_LINUX: >
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm &&
yum -y update &&
yum -y install gcc gcc-c++ make cmake postgresql13-devel proj81-devel geos39-devel gsl-devel &&
git clone --branch json-c-0.17 --depth 1 https://github.com/json-c/json-c &&
mkdir json-c-build &&
cd json-c-build &&
cmake ../json-c &&
make &&
make install &&
git clone --depth 1 https://github.com/MobilityDB/MobilityDB &&
mkdir MobilityDB/build &&
cd MobilityDB/build &&
cmake .. -DMEOS=on -DGEOS_INCLUDE_DIR=/usr/geos39/include/ -DGEOS_LIBRARY=/usr/geos39/lib64/libgeos_c.so -DGEOS_CONFIG=/usr/geos39/bin/geos-config -DPROJ_INCLUDE_DIRS=/usr/proj81/include/ -DPROJ_LIBRARIES=/usr/proj81/lib/libproj.so &&
make -j &&
make install
# Skip tests since they will be thoroughly tested in the next job
CIBW_TEST_SKIP: "*"
- uses: actions/upload-artifact@v4
with:
name: pymeos_cffi-wheels-${{ matrix.os }}
path: ./pymeos_cffi/wheelhouse/*.whl
test_wheels:
name: Test PyMEOS CFFI wheel - Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [ ubuntu-latest, macos-13, macos-14 ]
exclude:
# Necessary due to issue with macOS runners. See
# https://github.com/actions/setup-python/issues/808
# Can be removed once this PR is merged:
# https://github.com/actions/python-versions/pull/259
- os: macos-14
python-version: "3.8"
- os: macos-14
python-version: "3.9"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: pymeos_cffi-wheels-${{ matrix.os }}
path: ./pymeos_cffi_wheels
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install PyMEOS dependencies
run: |
python -m pip install --upgrade pip
pip install -f ./pymeos_cffi_wheels pymeos_cffi
pip install -r pymeos/dev-requirements.txt
- name: Test PyMEOS with pytest
working-directory: pymeos
run: pytest
upload_pypi:
name: Upload to PyPI
needs: [ test_wheels, build_sdist ]
runs-on: ubuntu-22.04
if: github.repository == 'MobilityDB/PyMEOS'
permissions:
id-token: write
steps:
- name: Get 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:
skip_existing: true
create_release:
name: Create GitHub Release
needs: [ test_wheels, build_sdist ]
runs-on: ubuntu-22.04
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
path: ./dist
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: ./dist/*