Skip to content

Commit 4ac045a

Browse files
build Python wheels with cibuildwheel and add to build workflow
1 parent a4f0cf5 commit 4ac045a

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- run: mkdir build
4747
- run: >
4848
cmake
49-
-DWITH_PYTHON=yes
49+
-DWITH_PYTHON=OFF
5050
-DFETCH_ABSEIL=ON
5151
-DCMAKE_CXX_STANDARD=17
5252
-DCMAKE_C_COMPILER_LAUNCHER=ccache
@@ -88,3 +88,50 @@ jobs:
8888
--test_verbose_timeout_warnings --test_output=errors \
8989
//...
9090
working-directory: src
91+
python:
92+
strategy:
93+
matrix:
94+
target:
95+
- cp3*-manylinux_x86_64
96+
- cp3*-macosx_x86_64
97+
- cp3*-macosx_arm64
98+
runs-on: ${{ contains(matrix.target, 'macos') && 'macos-latest' || contains(matrix.target, 'win') && 'windows-latest' || 'ubuntu-latest' }}
99+
steps:
100+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
101+
with:
102+
fetch-tags: true
103+
persist-credentials: false
104+
- uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
105+
with:
106+
package-dir: ./
107+
output-dir: dist/
108+
env:
109+
CIBW_BUILD: ${{ matrix.target }}
110+
CIBW_TEST_COMMAND: python -c "import s2geometry"
111+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
112+
with:
113+
name: dist-${{ runner.os }}-${{ runner.arch }}
114+
path: ./dist/
115+
python-publish:
116+
if: (github.event_name == 'release') && (github.event.action == 'released')
117+
needs: [python]
118+
runs-on: ubuntu-latest
119+
permissions:
120+
id-token: write
121+
attestations: write
122+
# Requires environment protection rules in GitHub Settings:
123+
# Settings > Environments > pypi > Add required reviewers
124+
environment:
125+
name: pypi
126+
url: https://pypi.org/p/s2geometry
127+
steps:
128+
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
129+
with:
130+
pattern: dist*
131+
path: dist/
132+
merge-multiple: true
133+
- uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
134+
with:
135+
subject-path: "dist/*"
136+
# To upload to PyPI without a token, add this workflow file as a Trusted Publisher in the project settings on the PyPI website
137+
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
'-DCALL_FROM_SETUP_PY:BOOL=ON',
2323
'-DBUILD_SHARED_LIBS:BOOL=OFF',
2424
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
25-
'-DWITH_PYTHON=ON'
25+
'-DWITH_PYTHON=ON',
26+
'-DBUILD_TESTS=OFF',
27+
'-DFETCH_ABSEIL=ON',
2628
]
2729
)
2830
],

0 commit comments

Comments
 (0)