-
Notifications
You must be signed in to change notification settings - Fork 11
211 lines (178 loc) · 6.13 KB
/
build_upload_pypi_wheels.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
name: Build and upload PyPI wheels and source dist
on:
release:
types: [published]
workflow_dispatch:
jobs:
build-wheels:
strategy:
matrix:
os: [windows-latest, macos-13, macos-latest, ubuntu-latest]
python-version: ['3.10', '3.11', '3.12']
include:
- os: windows-latest
wheelname: win
cibw_archs: "AMD64"
- os: macos-13
wheelname: macosx
cibw_archs: "x86_64"
- os: macos-latest
wheelname: macosx
cibw_archs: "arm64"
- os: ubuntu-latest
wheelname: manylinux
cibw_archs: "x86_64"
- python-version: '3.10'
version-tag: cp310
- python-version: '3.11'
version-tag: cp311
- python-version: '3.12'
version-tag: cp312
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install llvm on Macos
if: startsWith(matrix.os, 'macos')
shell: bash -l {0}
env:
# Homebrew location is different on Intel Mac
LLVM_DIR: ${{ (matrix.os == 'macos-13') && '/usr/local/opt/llvm' || '/opt/homebrew/opt/llvm' }}
run: |
brew install llvm
echo CC="${LLVM_DIR}/bin/clang" >> $GITHUB_ENV
echo LDFLAGS="-L${LLVM_DIR}/lib $LDFLAGS" >> $GITHUB_ENV
echo CPPFLAGS="-I${LLVM_DIR}/include $CPPFLAGS" >> $GITHUB_ENV
- name: Windows - find MSVC and set environment variables
if: startsWith(matrix.os, 'windows')
shell: bash -l {0}
env:
MSVC_PREFIX: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC'
run: |
echo "Available MSVC installations:"
ls "$MSVC_PREFIX"
MSVC_BIN=$(ls "$MSVC_PREFIX" | tail -n 1)\\bin\\HostX64\\x64
CC="$MSVC_PREFIX\\$MSVC_BIN\\cl.exe"
echo "CC: $CC"
echo "CC=$CC" >> $GITHUB_ENV
CC_LD="$MSVC_PREFIX\\$MSVC_BIN\\link.exe"
echo "CC_LD: $CC_LD"
echo "CC_LD=$CC_LD" >> $GITHUB_ENV
- name: Update Python pip, build, wheel, and twine
shell: bash -l {0}
run: |
python -m pip install --upgrade pip build wheel twine
- name: Build wheels from git checkout
uses: pypa/[email protected]
env:
CIBW_BUILD_FRONTEND: build
CIBW_BUILD: ${{ matrix.version-tag }}-*
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_SKIP: "*-musllinux*"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib"
CIBW_TEST_COMMAND: "python {package}/tests_and_analysis/test/run_tests.py"
with:
output-dir: wheelhouse
- name: Upload wheels as build artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }}-${{ matrix.cibw_archs }}
path: wheelhouse/*-${{ matrix.wheelname }}*_${{ matrix.cibw_archs }}.whl
if-no-files-found: error
build-sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Create source distribution
shell: bash -l {0}
run: |
pipx run build --sdist .
- name: Upload source dist as build artifact
uses: actions/upload-artifact@v4
with:
name: python-source-distribution
path: dist/
if-no-files-found: error
test-sdist:
needs: build-sdist
name: Test build from sdist on Windows
runs-on: windows-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Find MSVC and set environment variables
shell: bash -l {0}
env:
MSVC_PREFIX: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC'
run: |
echo "Available MSVC installations:"
ls "$MSVC_PREFIX"
MSVC_BIN=$(ls "$MSVC_PREFIX" | tail -n 1)\\bin\\HostX64\\x64
CC="$MSVC_PREFIX\\$MSVC_BIN\\cl.exe"
echo "CC: $CC"
echo "CC=$CC" >> $GITHUB_ENV
CC_LD="$MSVC_PREFIX\\$MSVC_BIN\\link.exe"
echo "CC_LD: $CC_LD"
echo "CC_LD=$CC_LD" >> $GITHUB_ENV
- name: Download sdist
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: List downloaded sdist
run: |
ls -R dist/
- name: Update pip
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
- name: Install from sdist
shell: bash -l {0}
run: python -m pip install $(find dist -name 'euphonic-*.tar.gz')[matplotlib,phonopy_reader,brille,test]
- name: Checkout repository (for tests and test data)
uses: actions/checkout@v4
- name: Delete source (to ensure we are testing INSTALLED version)
shell: bash -l {0}
run: rm -rf euphonic
- name: run tests
shell: bash -l {0}
run: python tests_and_analysis/test/run_tests.py --report
publish:
if: github.event_name == 'release'
needs: [build-wheels,test-sdist]
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/euphonic
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # This is possibly unnecessary?
- name: Download artifacts to Ubuntu environment
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: List Files
run: ls -R dist/
- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1