-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (168 loc) · 7.63 KB
/
deploy-conda.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
name: deploy-conda
on:
# push:
# branches:
# - main
release:
types:
- published
jobs:
build_wheels:
name: Build wheels, ${{ matrix.os }}, ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['cp39', 'cp310', 'cp311', 'cp312']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install OpenMP for mac
if: runner.os == 'macos'
run: |
# Starting from libomp>=15.0, the libomp installation in homebrew is "keg-only",
# meaning that libomp is only installed in homebrew's directory, but not moved
# to /usr/local to avoid other OpenMP installations (such as with gcc's version
# of OpenMP). To use the homebrew's version of OpenMP,the following symbolic
# links are created. Without these, the installation will fail with the error
# of "fatal error: omp.h file found"
brew install libomp
libomp_dir=$(brew --prefix libomp)
ln -sf ${libomp_dir}/include/omp-tools.h /usr/local/include/omp-tools.h
ln -sf ${libomp_dir}/include/omp.h /usr/local/include/omp.h
ln -sf ${libomp_dir}/include/ompt.h /usr/local/include/ompt.h
ln -sf ${libomp_dir}/lib/libomp.a /usr/local/lib/libomp.a
ln -sf ${libomp_dir}/lib/libomp.dylib /usr/local/lib/libomp.dylib
# Without this, installing cuda give error: no much space left on device
- name: Clear Cache
if: matrix.os != 'windows-latest'
run: rm -rf /opt/hostedtoolcache
- name: Build wheels (X86_64)
uses: pypa/cibuildwheel@v2.16.5
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_ARCHS_WINDOWS: "AMD64 x86"
CIBW_ARCHS_MACOS: "x86_64"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_BUILD: >
${{ matrix.python-version }}-win_amd64
${{ matrix.python-version }}-macosx_x86_64
${{ matrix.python-version }}-manylinux_x86_64
CIBW_SKIP: "pp* cp36-* cp37-* cp38-*"
CIBW_BUILD_VERBOSITY: 3
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
with:
output-dir: wheelhouse
# Upload all wheels to an artifact
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-wheel-${{ matrix.os }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl
retention-days: 1
build_conda:
needs: [build_wheels]
name: Build conda on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# To upload to PyPI on every tag starting with 'v', use the following:
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# To publish to pypi on each GitHub Release, use the following:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Clean runner space
if: matrix.os == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
docker system prune -af
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: artifacts-*
merge-multiple: true
path: dist
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
- name: Build and upload package
shell: bash -el {0}
run: |
conda install -y conda-build anaconda-client
conda config --set anaconda_upload yes
export PATH=$(conda info --root):$PATH
export PATH=$(conda info --root)/bin:$PATH
conda install -y -c s-ameli special_functions
conda build --output-folder conda-bld . -c s-ameli
env:
CYTHON_BUILD_IN_SOURCE: '1' # see setup.py. Avoids a bug when building with multiple python variants
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
# The manylinux wheels (after repaired with auditwheel) are very
# large in size. It is better to delete them. If we do not delete
# them, however, they will be deleted after the retention days,
# which I set to one day.
- name: Delete artifacts
uses: geekyeggo/delete-artifact@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: artifacts-*
test_conda:
needs: [build_conda]
name: Test on ${{ matrix.os }} and Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: myenv
- name: Checkout
uses: actions/checkout@v3
# Move source to avoid import from local folder
- name: Rename source
run: |
mv glearn glearn-DoNotImport
rm setup.cfg
# This is to prevent the error "libomp is already initialized",
# which occurs only in MacOS. To circumvent the error, the
# following script will remove libomp.dylib from imate package, and
# copies libomp.dylib from glearn to imate package.
# - name: Test (MacOS)
# if: matrix.os == 'macos-latest'
# run: |
# export PATH=$(conda info --root):$PATH
# export PATH=$(conda info --root)/bin:$PATH
# conda install -c s-ameli glearn -y
# conda install pytest -y
# chmod +x scripts/fix_libomp.sh
# ./scripts/fix_libomp.sh "$(conda info --root)/bin/python"
# pytest
# shell: bash
- name: Test (Linux, Windows)
if: matrix.os != 'macos-latest'
shell: bash -l {0}
run: |
conda install -c s-ameli glearn -y
conda install pytest -y
pytest