-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (175 loc) · 6.01 KB
/
python-publish.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
name: Build and Publish Python Wheels
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [published]
workflow_dispatch:
jobs:
build_wheels_linux:
name: Build wheels on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install HDF5
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
args: --release --out dist --find-interpreter
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: dist/*.whl
build_wheels_macos:
name: Build wheels on macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install HDF5
run: |
brew install hdf5
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
args: --release --out dist --find-interpreter
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos
path: dist/*.whl
build_wheels_windows:
name: Build wheels on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install h5py for HDF5 support
run: |
pip install h5py
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
args: --release --out dist --find-interpreter
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: dist/*.whl
build_manylinux:
name: Build manylinux wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build manylinux wheels
uses: PyO3/maturin-action@v1
with:
target: x86_64-unknown-linux-gnu
manylinux: 2014
args: --release --out dist --find-interpreter
before-script-linux: |
# Install HDF5 development files
yum install -y hdf5-devel
# Set environment variables for HDF5
export HDF5_DIR=/usr
# Ensure the built-in tryrun results are used (from your build.rs)
export HDF5_DISABLE_VERSION_CHECK=1
- name: Upload manylinux wheels
uses: actions/upload-artifact@v4
with:
name: wheels-manylinux
path: dist/*.whl
test_wheels:
name: Test wheels
needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows, build_manylinux]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install HDF5 (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev
- name: Install HDF5 (macOS)
if: runner.os == 'macOS'
run: |
brew install hdf5
- name: Install HDF5 (Windows)
if: runner.os == 'Windows'
run: |
pip install h5py
- name: Download wheels
uses: actions/download-artifact@v4
with:
path: dist
- name: Install package from wheel (Linux)
if: runner.os == 'Linux'
run: |
python -m pip install --upgrade pip
python -m pip install pytest
# Find appropriate wheel for this Python version
WHEEL_PATH=$(find dist/wheels-linux -name "*cp$(python -c 'import sys; print(f"{sys.version_info.major}{sys.version_info.minor}")')*" -o -name "*pp*" | head -n 1)
echo "Installing wheel: $WHEEL_PATH"
pip install $WHEEL_PATH
- name: Install package from wheel (macOS)
if: runner.os == 'macOS'
run: |
python -m pip install --upgrade pip
python -m pip install pytest
# Find appropriate wheel for this Python version
WHEEL_PATH=$(find dist/wheels-macos -name "*cp$(python -c 'import sys; print(f"{sys.version_info.major}{sys.version_info.minor}")')*" -o -name "*pp*" | head -n 1)
echo "Installing wheel: $WHEEL_PATH"
pip install $WHEEL_PATH
- name: Install package from wheel (Windows)
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install pytest
# Find appropriate wheel for this Python version using PowerShell
$PythonVersion = python -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')"
$WheelPath = Get-ChildItem -Path "dist\wheels-windows" -Recurse -Filter "*cp$PythonVersion*" | Select-Object -First 1 -ExpandProperty FullName
if (-not $WheelPath) {
$WheelPath = Get-ChildItem -Path "dist\wheels-windows" -Recurse -Filter "*pp*" | Select-Object -First 1 -ExpandProperty FullName
}
echo "Installing wheel: $WheelPath"
pip install $WheelPath
- name: Verify import
run: |
python -c "import hdf5_nuclear_data_reader; print('Import successful')"
- name: Run tests
run: |
pytest tests/
publish:
name: Publish package
needs: [test_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- name: Prepare distribution files
run: |
mkdir -p dist_combined
find dist -name "*.whl" -exec cp {} dist_combined \;
ls -la dist_combined/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist_combined/
skip-existing: true