forked from ochubar/SRW
-
Notifications
You must be signed in to change notification settings - Fork 1
212 lines (177 loc) · 6.14 KB
/
pypi_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
207
208
209
210
211
212
name: PyPI Publish
on:
release:
types: [published]
push:
pull_request:
workflow_dispatch:
jobs:
build-wheels:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
name: ${{ matrix.host-os }} / OpenMP ${{ matrix.openmp }}
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
# host-os: ["ubuntu-latest", "windows-latest", "macos-13", "macos-14"]
host-os: ["ubuntu-latest", "macos-13", "macos-14"]
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
openmp: ["off"]
fail-fast: false
env:
CIBW_SKIP: pp* cp36-* cp37-* cp*_i686 cp*-musllinux_*
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Set OpenMP mode
if: matrix.openmp == 'on'
run: |
export MODE="omp"
echo "MODE=${MODE}" >> $GITHUB_ENV
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: "env/python"
- uses: actions/upload-artifact@v4
with:
name: srwpy-wheels-${{ matrix.host-os }}
path: ./wheelhouse/*.whl
# TODO: add sdist generation/uploading step
# - name: Set MacOS Deployment Target
# if: runner.os == 'macOS'
# run: |
# export MACOSX_DEPLOYMENT_TARGET="10.15"
# echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
# - uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: testenv
# allow-softlinks: true
# auto-activate-base: false
# auto-update-conda: true
# channel-priority: flexible
# channels: conda-forge
# miniconda-version: "latest"
# python-version: "3.10"
# show-channel-urls: true
# use-only-tar-bz2: false
# - name: Set up Visual Studio shell
# if: runner.os == 'Windows'
# uses: egor-tensin/vs-shell@v2
# with:
# arch: x64
# - name: Install build requirements with conda
# if: runner.os != 'Linux'
# run: |
# set -vxeuo pipefail
# conda install -y cmake
# - name: Install OpenMP for macOS with conda
# if: runner.os == 'macOS' && matrix.openmp == 'on'
# run: |
# set -vxeuo pipefail
# conda install -y -c conda-forge llvm-openmp
# # NOTE: This step is not needed for fast tests.
# # - name: Install mpi4py for Unix with conda
# # if: runner.os != 'Windows'
# # run: |
# # set -vxeuo pipefail
# # conda install -y -c conda-forge mpi4py openmpi
# - name: Install cibuildwheel on Linux
# if: runner.os == 'Linux'
# run: |
# set -vxeuo pipefail
# python -m pip install --upgrade pip
# python -m pip install cibuildwheel
# echo "CIBW_BEFORE_ALL=pip install cmake" >> $GITHUB_ENV
# PYTH_VER=${{ matrix.python-version }}
# PYTH_VER=${PYTH_VER//.}
# echo "CIBW_BUILD="cp$PYTH_VER-manylinux*"" >> $GITHUB_ENV
# - name: Build wheel on Linux
# if: runner.os == 'Linux'
# run: |
# set -vxeuo pipefail
# python -VV
# python -m cibuildwheel --output-dir dist env/python
# ls -la dist/*
# - name: Build wheel on Windows/Mac
# if: runner.os != 'Linux'
# run: |
# set -vxeuo pipefail
# cd env/python
# python -VV
# python setup.py bdist_wheel
# ls -la dist/*
# mkdir -p ../../dist
# cp dist/*.whl ../../dist/
# - name: Publish wheels to GitHub artifacts
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist/*
test-wheels:
needs: build-wheels
name: ${{ matrix.host-os }} / Python ${{ matrix.python-version }}
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
# host-os: ["ubuntu-latest", "windows-latest", "macos-13", "macos-14"]
host-os: ["ubuntu-latest", "macos-13", "macos-14"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Set environment variables
run: |
export PYTHONVER=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
echo "PYTHONVER=${PYTHONVER}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: srwpy-wheels-${{ matrix.host-os }}
path: wheelhouse
- name: Display structure of downloaded files
run: ls -laR wheelhouse/
- name: Install the package and test requirements
run: |
set -vxeuo pipefail
python -m pip install -v wheelhouse/*-cp${PYTHONVER}-*.whl
# Smoke import test:
python -c "import srwpy; import srwpy.srwlpy"
# Check CLI tools:
srw-viewer --help
python -m pip install -r env/python/requirements-dev.txt
python -m pip list
- name: Run fast tests
run: |
set -vxeuo pipefail
cd env/python
pytest -k fast
publish-to-pypi:
# Hints from:
# - https://github.com/pypa/gh-action-pypi-publish/discussions/28
# - https://github.com/Lightning-AI/lightning/blob/master/.github/workflows/release-pypi.yml
if: github.event_name == 'release'
name: Publish to PyPI
needs: test-wheels
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Download wheels from GitHub artifacts
uses: actions/download-artifact@v3
with:
name: wheels
path: dist/
- name: Publish wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist/