-
Notifications
You must be signed in to change notification settings - Fork 263
166 lines (139 loc) · 4.71 KB
/
cibuildwheel.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
name: Wheels
on:
pull_request:
push:
tags:
- "v*"
release:
types:
- published
permissions:
contents: read
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: 3.x
- name: Install APT packages
if: contains(${{ matrix.os }}, 'ubuntu')
run: |
sudo apt update
sudo apt install libhdf5-dev libnetcdf-dev
- name: Build sdist
run: >
pip install build
&& python -m build --sdist . --outdir dist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build_bdist:
name: "Build ${{ matrix.os }} (${{ matrix.arch }}) wheels"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
arch: ["x86_64", "arm64"]
exclude:
- os: ubuntu-latest
arch: arm64
steps:
- uses: actions/checkout@v4
- name: "Building ${{ matrix.os }} (${{ matrix.arch }}) wheels"
uses: pypa/cibuildwheel@v2.15.0
env:
# Skips pypy and musllinux for now.
CIBW_SKIP: "pp* cp36-* cp37-* *-musllinux*"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD_FRONTEND: build
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BEFORE_BUILD_LINUX: >
dnf install -y epel-release
&& dnf install -y hdf5-devel libcurl-devel
&& sh .ci/build_deps.sh
CIBW_BEFORE_BUILD_MACOS: brew install hdf5 netcdf
CIBW_TEST_SKIP: "*_arm64"
CIBW_TEST_REQUIRES: pytest cython packaging
CIBW_TEST_COMMAND: >
python -c "import netCDF4; print(f'netCDF4 v{netCDF4.__version__}')" &&
cd {project}/test && python run_all.py
- uses: actions/upload-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/wheelhouse/*.whl
build_wheels_windows:
name: Build wheels for ${{matrix.arch}} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
arch: [win_amd64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: 3.x
- name: Setup Micromamba Python ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
environment-name: build
init-shell: bash
create-args: >-
python=${{ matrix.python-version }} libnetcdf=4.9.2 --channel conda-forge
- name: Install cibuildwheel
run: |
python -m pip install --upgrade cibuildwheel delvewheel
- name: Build wheels for Windows (${{ matrix.arch }})
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-${{ matrix.arch }} cp310-${{ matrix.arch }} cp311-${{ matrix.arch }} cp312-${{ matrix.arch }}"
CIBW_ENVIRONMENT_WINDOWS: >
HDF5_DIR="C:\\Users\\runneradmin\\micromamba\\envs\\build\\Library"
netCDF4_DIR="C:\\Users\\runneradmin\\micromamba\\envs\\build\\Library"
PATH="C:\\Users\\runneradmin\\micromamba\\envs\\build\\Library\\bin;${PATH}"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
delvewheel show {wheel}
&& delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_REQUIRES: pytest cython packaging
CIBW_TEST_COMMAND: >
python -c "import netCDF4; print(f'netCDF4 v{netCDF4.__version__}')"
&& xcopy {project}\\test . /E/H
&& python run_all.py
- uses: actions/upload-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/wheelhouse/*.whl
show-artifacts:
needs: [build_bdist, build_sdist, build_wheels_windows]
name: "Show artifacts"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- shell: bash
run: |
ls -l ${{ github.workspace }}/dist
publish-artifacts-pypi:
needs: [build_bdist, build_sdist, build_wheels_windows]
name: "Publish to PyPI"
runs-on: ubuntu-latest
# upload to PyPI for every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
print_hash: true