forked from dftd4/dftd4
-
Notifications
You must be signed in to change notification settings - Fork 4
220 lines (194 loc) · 6.23 KB
/
wheel.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
213
214
215
216
217
218
219
220
name: wheel
on:
push:
branches:
- main
paths-ignore:
- "doc*/**"
- "./*.ya?ml"
- "**/*.adoc"
- "**/*.md"
- "**/*.rst"
pull_request:
paths-ignore:
- "doc*/**"
- "./*.ya?ml"
- "**/*.adoc"
- "**/*.md"
- "**/*.rst"
workflow_dispatch:
release:
types: [published]
jobs:
source:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Python
uses: mamba-org/setup-micromamba@v1
with:
environment-file: assets/ci/build-env.yaml
- run: |
meson setup _build
meson dist -C _build --no-tests --include-subprojects
mv _build/meson-dist/*.tar.xz .
- uses: actions/upload-artifact@v4
with:
name: dftd4-source
path: ./*.tar.xz
retention-days: 5
sdist:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Python
uses: mamba-org/setup-micromamba@v1
with:
environment-file: assets/ci/python-env.yaml
create-args: >-
meson-python
python-build
- name: Reorganize repository
run: |
git config user.email ""
git config user.name "dummy"
git subtree add --prefix python/subprojects/dftd4 . HEAD
git mv {assets,python/dftd4}/parameters.toml
git commit -m "Python dist"
- name: Build source distribution
run: |
python -m build python/ --sdist --outdir . -n
- name: Upload source distribution as artifact
uses: actions/upload-artifact@v4
with:
name: dftd4-python-sdist
path: ./*.tar.gz
retention-days: 5
wheels:
needs:
- sdist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- macos-13
python: ["39", "310", "311", "312", "313"]
include: # Python 3.7 and 3.8 is not supported on 'macos-latest'
- os: ubuntu-latest
python: "37"
- os: ubuntu-latest
python: "38"
- os: macos-13
python: "37"
- os: macos-13
python: "38"
defaults:
run:
shell: bash -l {0}
steps:
# Set up Python to host 'cibuildwheel'
- uses: actions/setup-python@v5
with:
python-version: "3.x"
# Install 'cibuildwheel' as the driver for building wheels
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.20.0
# Download the source distribution from above
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: dftd4-python-sdist
# Build wheels for all supported Python versions
- name: Build wheels
run: python -m cibuildwheel --output-dir . *.tar.gz
env:
CIBW_PLAT: ${{ contains(matrix.os, 'macos') && '-Dlapack=openblas' || '' }}
CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }}
CIBW_ARCHS_LINUX: x86_64
CIBW_BUILD: "*${{ matrix.python }}-*"
# MM: Package installation (yum install ...) works differently on musllinux
CIBW_SKIP: "*musllinux*"
# Control verbosity of the 'pip wheel' output
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_ALL_LINUX: yum install -y lapack-devel
# Delete all other (=/= gcc-14) GCC versions to avoid conflicts in delocation of the wheel
# MM: 'openblas' from brew requires gcc@14, using a different version for building leads to delocation errors
# MM: gcc@14 needs macOS14
CIBW_BEFORE_ALL_MACOS: |
brew uninstall gcc@12
brew uninstall gcc@13
brew autoremove
brew install openblas
# Set macOS variables to find gfortran, lapack, and avoid testing against macOS earlier than 14 (see above)
CIBW_ENVIRONMENT_MACOS: >
CC=gcc-14 CXX=g++-14 FC=gfortran-14
PKG_CONFIG_PATH="$(brew --prefix openblas)/lib/pkgconfig"
LDFLAGS="-L$(brew --prefix openblas)/lib -L/usr/local/lib"
CPPFLAGS="-I$(brew --prefix openblas)/include"
MACOSX_DEPLOYMENT_TARGET=${{ matrix.os == 'macos-13' && '13.0' || '14.0' }}
# Upload the built wheels as artifacts
- uses: actions/upload-artifact@v4
with:
name: dftd4-python-${{ matrix.os }}-${{ matrix.python }}
path: ./*.whl
retention-days: 5
release:
needs:
- source
- sdist
- wheels
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }} # This will download all files
- name: Create SHA256 checksums
run: |
set -ex
for output in dftd4*/dftd4*; do
pushd $(dirname "$output")
sha256sum $(basename "$output") | tee $(basename "$output").sha256
popd
done
- name: Copy release artifacts
run: |
mkdir dist/
cp -v dftd4*/dftd4*.whl dftd4*/dftd4*.tar.gz dist/
- name: Publish to Test PyPI
if: ${{ github.event_name == 'release' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Upload assets
uses: svenstaro/upload-release-action@v2
if: ${{ github.event_name == 'release' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dftd4*/dftd4*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
- name: Publish to PyPI
if: ${{ github.event_name == 'release' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}