-
Notifications
You must be signed in to change notification settings - Fork 33
194 lines (168 loc) · 6.62 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
name: Python package build
on:
push:
pull_request:
workflow_dispatch:
inputs:
publish_to_pypi:
description: 'Publish wheels and sdist to PyPI'
required: true
default: 'false'
defaults:
run:
shell: bash -l {0}
jobs:
build:
name: Build ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: .github/python_test_env.yml
- name: Set development version number
run: |
COMMIT_NUM=$(git rev-list $(git describe --tags --abbrev=0).. --count)
echo "${COMMIT_NUM} commits since last tag"
sed -i.old "s/-dev/-dev${COMMIT_NUM}/" cmake/VersionSource.cmake
- name: Install
run: python -m pip install . -v
- name: Test
run: python -m pytest --cov exactextract --cov-report lcov python/tests
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
files: coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
- name: Build source distribution
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: python -m build . --sdist
- name: Check source distribution
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: python -m twine check dist/*.gz
- name: Upload distribution(s)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: release-sdist
path: ./dist/*.tar.gz
# Largely taken from https://github.com/shapely/shapely/blob/main/.github/workflows/release.yml
build_wheels:
name: Build ${{ matrix.arch }} wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' || github.event_name == 'workflow_dispatch'
env:
GEOS_VERSION: "3.12.2"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
arch: x86_64
- os: windows-2019
arch: x86
msvc_arch: x86
- os: windows-2019
arch: AMD64
msvc_arch: x64
- os: macos-13
arch: x86_64
cmake_osx_architectures: x86_64
- os: macos-14
arch: arm64
cmake_osx_architectures: arm64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Cache GEOS build
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ env.GEOS_VERSION }}-${{ hashFiles('ci/*') }}
- name: Add GEOS LICENSE
run: |
cp ci/wheels/licenses/LICENSE_GEOS .
shell: bash
- name: Add MSVC LICENSE
run: |
cp ci/wheels/licenses/LICENSE_win32 .
shell: bash
if: ${{ matrix.os == 'windows-2019' }}
- name: Activate MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}
if: ${{ matrix.msvc_arch }}
- name: Set development version number
run: |
COMMIT_NUM=$(git rev-list $(git describe --tags --abbrev=0).. --count)
echo "${COMMIT_NUM} commits since last tag"
sed -i.old "s/-dev/-dev${COMMIT_NUM}/" cmake/VersionSource.cmake
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: cp36-* cp37-* cp38-* pp* *musllinux* *-manylinux_i686
CIBW_TEST_SKIP: "cp38-macosx_arm64"
CIBW_ENVIRONMENT_LINUX:
GEOS_VERSION=${{ env.GEOS_VERSION }}
GEOS_INSTALL=/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_DIR=/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_CONFIG=/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}/bin/geos-config
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}/lib
CIBW_ENVIRONMENT_MACOS:
GEOS_INSTALL=${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_DIR=${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_CONFIG=${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}/bin/geos-config
MACOSX_DEPLOYMENT_TARGET=10.9
CMAKE_OSX_ARCHITECTURES='${{ matrix.cmake_osx_architectures }}'
CIBW_ENVIRONMENT_WINDOWS:
GEOS_INSTALL='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}'
GEOS_DIR='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}'
GEOS_LIBRARY_PATH='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\lib'
GEOS_INCLUDE_PATH='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\include'
CIBW_BEFORE_ALL: ./ci/wheels/install_geos.sh
CIBW_BEFORE_ALL_WINDOWS: ci\wheels\install_geos.cmd
CIBW_BEFORE_BUILD_WINDOWS:
pip install delvewheel
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair --add-path ${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\bin -w {dest_dir} {wheel}
CIBW_BUILD_FRONTEND: "pip; args: -vvv"
CIBW_TEST_REQUIRES: pytest numpy
CIBW_TEST_COMMAND: >
python -c "import exactextract; exactextract.__version__" &&
python -m pytest {package}/python/tests/test_exact_extract.py {package}/python/tests/test_operation.py {package}/python/tests/test_processor.py -s -v
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
upload_pypi:
name: Publish on PyPI
needs: [build_wheels, build]
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event.inputs.publish_to_pypi == 'true'
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: dist
- name: Upload Release Assets to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
repository-url: ${{ github.event_name == 'workflow_dispatch' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}