-
Notifications
You must be signed in to change notification settings - Fork 33
300 lines (264 loc) · 11.6 KB
/
build.yml
File metadata and controls
300 lines (264 loc) · 11.6 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# Unified workflow for building, building docs, and conditionally deploying to PyPI for NVISII
name: CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Triggers the workflow for when a new release is tagged (This will enable also deploying to PyPI)
release:
types: [ created ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# This workflow always begins with a build on all supported platforms, defined by the matrix
build:
name: ${{ matrix.pretty }} - Python ${{ matrix.python-version }} - OptiX ${{ matrix.optix-version }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019]
python-version: ['3.9', '3.10'] # '3.11' has some issues atm...
optix-version: [70, 71, 72]
include:
# Includes the value for matrix.container when the OS is Ubuntu, to use manylinux complaint CentOS version.
# For Windows, matrix.container remains undefined and the build runs on the host VM instead of within a container.
- os: ubuntu-20.04
container: 'quay.io/pypa/manylinux2014_x86_64:2021-01-12-c8250d8'
pretty: 'Linux'
- os: windows-2019
pretty: 'Windows'
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
uses: actions/checkout@v2
# setuptools_scm requires history, so all commits are fetched by setting 0
with:
fetch-depth: 0
- name: Linux Dependencies (CUDA, X, Python)
if: runner.os == 'Linux'
shell: bash
run: |
# Install Python Dependencies
PY=${{ matrix.python-version }}
[[ ${PY:2:1} < 8 ]] && M=m || M=""
PYVER=cp${PY:0:1}${PY:2:1}-cp${PY:0:1}${PY:2:1}${M}
PYEXEC=/opt/python/${PYVER}/bin/python
$PYEXEC -m pip install --upgrade pip
$PYEXEC -m pip install setuptools setuptools_scm numpy==1.19.5
# Install CMake
$PYEXEC -m pip install cmake
CMAKEEXEC=/opt/python/${PYVER}/bin/cmake
$CMAKEEXEC --version
# Install CUDA
yum-config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
yum clean all
yum -y erase devtoolset-9-binutils devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-gcc-gfortran
yum -y install devtoolset-8-binutils devtoolset-8-gcc devtoolset-8-gcc-c++
yum -y install cuda-compiler-10-2 cuda-cudart-dev-10-2 cuda-minimal-build-10-2
yum -y install libXi-devel
yum -y install xorg-x11-server-devel
yum -y install libXinerama-devel
yum -y install glfw-devel
yum -y install wget
yum -y install pcre-devel
yum -y install unar
yum -y install zip
# This symlink comes as a part of the cuda-10.2 package, which is being specifically avoided,
# but this symlink makes CMake's FindCUDA behave nicely.
ln -s /usr/local/cuda-10.2 /usr/local/cuda
source /opt/rh/devtoolset-8/enable
# Build a version of SWIG we can use
mkdir build
cd build
wget http://prdownloads.sourceforge.net/swig/swig-4.0.2.tar.gz
tar xzf swig-4.0.2.tar.gz
cd swig-4.0.2
./configure --prefix $(pwd)
make
make install
ls
cd ../
- name: Linux Build
if: runner.os == 'Linux'
shell: bash
env:
OPTIX_VERSION: ${{ matrix.optix-version }}
run: |
source /opt/rh/devtoolset-8/enable
PY=${{ matrix.python-version }}
[[ ${PY:2:1} < 8 ]] && M=m || M=""
PYVER=cp${PY:0:1}${PY:2:1}-cp${PY:0:1}${PY:2:1}${M}
PYEXEC=/opt/python/${PYVER}/bin/python
CMAKEEXEC=/opt/python/${PYVER}/bin/cmake
cd build
$CMAKEEXEC ../ \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda-10.2/bin/nvcc \
-DCUDA_CUDA_LIBRARY=/usr/local/cuda-10.2/targets/x86_64-linux/lib/stubs/libcuda.so \
-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-10.2/bin/nvcc \
-DCUDA_INCLUDE_DIRS=/usr/local/cuda-10.2/targets/x86_64-linux/include \
-DCUDA_CUDART_LIBRARY=/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudart.so \
-DSWIG_DIR="./swig-4.0.2/share/swig/4.0.2/" \
-DSWIG_EXECUTABLE="swig-4.0.2/bin/swig" \
-DPython_INCLUDE_DIRS=/opt/python/${PYVER}/include/python${PY:0:1}.${PY:2:1}${M}/ \
-DPython_NumPy_INCLUDE_DIRS=/opt/python/${PYVER}/lib/python${PY:0:1}.${PY:2:1}/site-packages/numpy/core/include/ \
-DPython_VERSION_MAJOR=${PY:0:1} \
-DPython_VERSION_MINOR=${PY:2:2} \
-DCMAKE_BUILD_TYPE=Release \
$CMAKEEXEC --build . --config Release --target install
cd ..
cd install
# need to temporarily remove libcuda.so.1 from library
cd nvisii
patchelf --remove-needed libcuda.so.1 _nvisii.so
cd ../
# now make the bdistwheel
$PYEXEC setup.py bdist_wheel
cd dist
# audit the bdistwheel for use on all linux distros
# and use the same dir for both .py and .so files
auditwheel repair -L "" *.whl
# add back on the libcuda.so.1 to the library
cd wheelhouse
unar -d *.whl
cd nvisii*
cd nvisii
patchelf --add-needed libcuda.so.1 _nvisii.so
# list libraries for manual verification
ldd _nvisii.so
cd ..
cd ..
rm *.whl
NAME=$(ls -1 .)
cd ${NAME}
zip -r ../${NAME}.whl ./*
# move the modified manylinux wheel to the "install/dist" folder to be uploaded
rm ../../*.whl
cp ../*.whl ../../
# Python configuration by github is only valid on their VMs (not inside the manylinux container), so only run on windows.
- name: Configure Python on Windows
if: runner.os == 'Windows'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Windows Dependencies (CUDA)
if: runner.os == 'Windows'
shell: powershell
run: |
$CUDA_VERSION_FULL = "10.2.89"
$CUDA_REPO_PKG_REMOTE = "http://developer.download.nvidia.com/compute/cuda/10.2/Prod/network_installers/cuda_10.2.89_win10_network.exe"
$CUDA_REPO_PKG_LOCAL = "cuda_10.2.89_win10_network.exe"
$CUDA_PACKAGES = "nvcc_10.2 cudart_10.2"
# Download the cuda network installer
Invoke-WebRequest $CUDA_REPO_PKG_REMOTE -OutFile $CUDA_REPO_PKG_LOCAL | Out-Null
# Invoke silent install of CUDA (via network installer)
Start-Process -Wait -FilePath .\"$($CUDA_REPO_PKG_LOCAL)" -ArgumentList "-s $($CUDA_PACKAGES)"
- name: Windows Build
if: runner.os == 'Windows'
env:
OPTIX_VERSION: ${{ matrix.optix-version }}
run: |
pip install --upgrade setuptools setuptools_scm wheel numpy==1.19.5
mkdir build
cd build
cmake ../ -DCMAKE_CUDA_COMPILER="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/bin/nvcc.exe" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2" -DPYTHON_VERSION="${{matrix.python-version}}"
cmake --build . --config Release --target install
cd ..
cd install
python setup.py bdist_wheel
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: nvisii-${{ matrix.os }}-python${{ matrix.python-version }}-optix${{ matrix.optix-version }}
path: install/dist/*.whl
docs:
needs: build
runs-on: ubuntu-20.04
# Only build/commit new docs if this is an update to master (ignore runs triggered within pull request)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
name: nvisii-ubuntu-20.04-python3.9-optix72
- name: Switch to gh-pages branch and merge in latest master
run: |
# tmate for debugging
#sleep 120
#echo hello
#wget https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-amd64.tar.xz
#tar xf tmate-2.4.0-static-linux-amd64.tar.xz
#cd tmate-2.4.0-static-linux-amd64
#./tmate -F
#cd ..
git config user.name github-actions
git config user.email github-actions@github.com
git checkout gh-pages
git merge master
- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- name: Build Docs
run: |
echo Build Docs here
python -m pip install sphinx sphinx_rtd_theme sphinx-git
python -m pip install nvisii*.whl
cd docs
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libcuda.so make html
#- name: Display structure of built files
# run: |
# ls -R
# Upload to gh-pages branch
- name: Push html pages to gh-pages branch
run: |
rm -rf ./docs/_sources/
rm -rf ./docs/_static/
mv ./docs/build/html/* ./docs/
touch ./docs/.nojekyll
git config user.name github-actions
git config user.email github-actions@github.com
git add ./docs/
git commit -m "Update docs from master"
git push origin gh-pages
deploy:
needs: build
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install Dependencies (twine)
run: |
ls -R # Show all downloaded artifacts
python -m pip install --upgrade pip
python -m pip install twine
- name: Upload to test pypi
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
twine upload --repository-url https://test.pypi.org/legacy/ */*.whl
- name: Upload to pypi
if: success() && !github.event.release.prerelease
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload */*.whl