-
Notifications
You must be signed in to change notification settings - Fork 15
193 lines (161 loc) · 5.32 KB
/
build.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
name: Build
on:
workflow_dispatch:
push:
branches:
- develop/*
pull_request:
branches:
- master
release:
types: [ published ]
defaults:
run:
shell: bash
jobs:
build_wheels_windows:
name: Build wheels on Windows
runs-on: windows-latest
strategy:
fail-fast: False
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
run: |
python -m pip install -U pip numpy swig wheel setuptools
python setup.py bdist_wheel -d dist
ls -al ./dist
- name: Place wheels in artifacts folder
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.python-version }}
path: ./dist/*.whl
build_wheels_unix:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: False
matrix:
os: [ ubuntu-latest, macos-latest, macos-14 ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build wheels
env:
# only build CPython-3.9+ and skip 32-bit builds
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: "*-manylinux_i686 *-musllinux*"
# use latest build
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64
CIBW_BEFORE_ALL_MACOS: brew install swig
CIBW_BEFORE_BUILD: pip install numpy swig
run: |
python -m pip install -U pip cibuildwheel
python -m cibuildwheel --output-dir dist
ls -R dist
- name: Place wheels in artifacts folder
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: ./dist/*.whl
test-wheels:
name: Test wheels
needs: [ build_wheels_windows, build_wheels_unix ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest, macos-14 ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Retrieve packages
uses: actions/download-artifact@v4
with:
path: dist
- name: List items
run: |
ls -alR dist
- name: Test Package Installation
run: |
python -m pip install --upgrade pip
# list all files in the dist folder
ls -R dist
# finds path to the right wheel or source file to install later
os=$(echo ${{ runner.os }} | awk '{print tolower($0)}' | head -c3)
# version refers to the python version. So 3.8 -> 38
version=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
chunk="windows-*"
else
chunk="${{matrix.os}}"
fi
# this finds files like
# nlopt-2.6.2-cp36-cp36m-win_amd64.whl
# nlopt-2.6.2-cp36-cp36m-manylinux10_amd64.whl
# nlopt-2.7.1-cp310-cp310-win_amd64.whl
file=$(find dist/${chunk} -name "nlopt-*${version}*${os}*.whl" -type f);
echo "Installing file: ${file}"
pip install ${file}
python extern/nlopt/test/t_python.py
deploy:
name: Deploy packages
runs-on: ubuntu-latest
needs: test-wheels
steps:
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Retrieve packages
uses: actions/download-artifact@v4
with:
path: dist
- name: Install twine
run: pip install twine
- name: Move files to top level directory
run: |
ls -ltR dist
python - << EOF
from pathlib import Path
import shutil
d = Path('dist')
for f in d.rglob('*.whl'):
shutil.move(f, d / f.name)
for f in d.iterdir():
if f.is_dir():
shutil.rmtree(f)
EOF
- name: Upload packages to testpypi
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_TEST_TOKEN_NAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
run: python -m twine upload --skip-existing --repository testpypi dist/* --verbose
- name: Upload packages to pypi
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: ${{ secrets.PYPI_PROD_TOKEN_NAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PROD_API_TOKEN }}
run: python -m twine upload --skip-existing dist/* --verbose