-
Notifications
You must be signed in to change notification settings - Fork 10
346 lines (287 loc) · 14 KB
/
Copy pathbundle_with_dakota_macos.yml
File metadata and controls
346 lines (287 loc) · 14 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
name: macos-run-tests-build-docs
permissions:
contents: read
on:
workflow_call:
inputs:
ERT_SHOW_BACKTRACE:
required: true
type: string
NO_PROJECT_RES:
required: true
type: string
BOOST_VERSION:
required: true
type: string
DAKOTA_VERSION:
required: true
type: string
INSTALL_DIR:
required: true
type: string
jobs:
build_dependencies:
strategy:
fail-fast: true
matrix:
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
python-version: [ '3.12', '3.13', '3.14' ]
os: [ 'macos-15' ]
runs-on: ${{ matrix.os }}
timeout-minutes: 90
name: "Build 🛞 (${{ matrix.python-version }}, ${{ matrix.os }})"
env:
INSTALL_DIR: ${{ inputs.INSTALL_DIR }}
SYSTEM_VERSION_COMPAT: 0
MACOSX_DEPLOYMENT_TARGET: '15.0'
steps:
- name: Echo env and inputs
run: |
echo "inputs.ERT_SHOW_BACKTRACE=${{ inputs.ERT_SHOW_BACKTRACE }}"
echo "inputs.NO_PROJECT_RES=${{ inputs.NO_PROJECT_RES }}"
echo "inputs.BOOST_VERSION=${{ inputs.BOOST_VERSION }}"
echo "inputs.DAKOTA_VERSION=${{ inputs.DAKOTA_VERSION }}"
echo "inputs.INSTALL_DIR=${{ inputs.INSTALL_DIR }}"
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
- name: Cache Homebrew Bundler RubyGems
id: cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-
- name: Install Homebrew Bundler RubyGems
if: steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
- name: Check MacOS version
run: |
python --version
echo "matrix.os = ${{ matrix.os }}"
sw_vers -productVersion
which python
which pip
python -c "import platform; mac_version=platform.mac_ver(); print('macOS version: '+mac_version[0])"
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: cache-package
with:
key: ${{ matrix.os }}_python-${{ matrix.python-version }}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}
path: ${{ github.workspace }}/python-${{ matrix.python-version}}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}.tar.gz
- name: Checkout Carolina
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Install brew gcc
run: brew install gcc
- name: Install dependencies
if: steps.cache-package.outputs.cache-hit != 'true'
run: |
python -m pip install -U pip
python -m pip install numpy
python -m pip install "cmake<4"
- name: Build needed boost libraries
if: steps.cache-package.outputs.cache-hit != 'true'
run: |
python --version
mkdir -p /tmp/build
cd /tmp/build
BOOST_VERSION_UNDERSCORES=$(echo ${{ inputs.BOOST_VERSION }} | sed 's/\./_/g')
wget --quiet https://sourceforge.net/projects/boost/files/boost/${{ inputs.BOOST_VERSION }}/boost_${BOOST_VERSION_UNDERSCORES}.tar.bz2
tar -xf boost_${BOOST_VERSION_UNDERSCORES}.tar.bz2
cd boost_${BOOST_VERSION_UNDERSCORES}
./bootstrap.sh --with-libraries=python,filesystem,program_options,regex,serialization,system --with-python-version=${{ matrix.python_version }}
# replace python version
python_version=$(python --version | sed -E 's/.*([0-9]+\.[0-9]+)\.([0-9]+).*/\1/')
python_bin_include_lib=" using python : $python_version : $(python -c "from sysconfig import get_paths as gp; g=gp(); print(f\"$(which python) : {g['include']} : {g['stdlib']} ;\")")"
sed -i '' "s|.*using python.*|$python_bin_include_lib|" project-config.jam
cd /tmp/build/boost_${BOOST_VERSION_UNDERSCORES}
./b2 install -j4 -a cxxflags="-std=c++17" --prefix=${GITHUB_WORKSPACE}/${INSTALL_DIR}
- name: Build dakota
if: steps.cache-package.outputs.cache-hit != 'true'
run: |
CAROLINA_DIR=$(pwd)
export PYTHON_EXECUTABLE=$(which python)
export PYTHON_INCLUDE_DIR=$(python -c "from sysconfig import get_paths as gp; print(gp()['include'])")
mkdir -p /tmp/build
cd /tmp/build
wget --quiet --no-check-certificate \
https://github.com/snl-dakota/dakota/releases/download/v${{ inputs.DAKOTA_VERSION }}/dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli.tar.gz
# CMake uses FC as fortran compiler
BREW_CELLAR=$(brew --prefix)/Cellar
FORTRAN_FULLPATH=$(find $BREW_CELLAR -name "*gfortran")
FORTRAN_PATH=$(dirname "$FORTRAN_FULLPATH")
export PATH=$FORTRAN_PATH:$PATH
tar xf dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli.tar.gz
EIGEN_CMAKE_PATH=dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli/packages/external/eigen3/share/eigen3/cmake
# resolve issue where tar could contain corrupt Eigen3Config.cmake file
if [ ! -f $EIGEN_CMAKE_PATH/Eigen3Config.cmake ]; then
mkdir temp_dakota
cd temp_dakota
wget --quiet --no-check-certificate \
https://github.com/snl-dakota/dakota/releases/download/v${{ inputs.DAKOTA_VERSION }}/dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli.zip
# extract file from zip archive only
unzip -o dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli.zip "$EIGEN_CMAKE_PATH/Eigen3Config.cmake"
cp $EIGEN_CMAKE_PATH/Eigen3Config.cmake ..
cd ..
rm -rf temp_dakota
# replace the offending file
rm $EIGEN_CMAKE_PATH/EIGEN3Config.cmake
cp Eigen3Config.cmake $EIGEN_CMAKE_PATH
fi
cd dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli
patch -p1 < $CAROLINA_DIR/dakota_manylinux_install_files/CMakeLists_includes.patch
patch -p1 < $CAROLINA_DIR/dakota_manylinux_install_files/install_macos_libs.patch
PYTHON_INCLUDE_DIR="$(python -c "from sysconfig import get_paths as gp; g=gp(); print(f\"{g['include']} \")")"
mkdir -p build
cd build
cmake \
-DCMAKE_CXX_STANDARD=17 \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_CXX_FLAGS="-I$PYTHON_INCLUDE_DIR -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -D_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS" \
-DDAKOTA_PYTHON_DIRECT_INTERFACE=ON \
-DDAKOTA_PYTHON_DIRECT_INTERFACE_NUMPY=ON \
-DDAKOTA_DLL_API=OFF \
-DHAVE_X_GRAPHICS=OFF \
-DDAKOTA_ENABLE_TESTS=OFF \
-DDAKOTA_ENABLE_TPL_TESTS=OFF \
-DCMAKE_BUILD_TYPE='Release' \
-DDAKOTA_NO_FIND_TRILINOS:BOOL=TRUE \
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/${INSTALL_DIR}" \
..
make -j4 install
- name: Package built boost and dakota
if: steps.cache-package.outputs.cache-hit != 'true'
run: |
cd ${GITHUB_WORKSPACE}
tar zcf python-${{ matrix.python-version}}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}.tar.gz ${INSTALL_DIR}
- name: Cache boost and dakota
if: steps.cache-package.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/python-${{ matrix.python-version}}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}.tar.gz
key: ${{ matrix.os }}_python-${{ matrix.python-version }}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: restore-cached-package
with:
key: ${{ matrix.os }}_python-${{ matrix.python-version }}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}
path: ${{ github.workspace }}/python-${{ matrix.python-version}}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}.tar.gz
- name: Unpack boost + dakota
run: |
cd $HOME
tar zxf ${GITHUB_WORKSPACE}/python-${{ matrix.python-version}}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}.tar.gz
- name: Set some env vars
run: |
echo "PATH=${PATH}:${HOME}/${INSTALL_DIR}/bin"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/${INSTALL_DIR}/lib"
echo "DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${HOME}/${INSTALL_DIR}/lib:$INSTALL_DIR/bin"
echo "PATH=${PATH}:${HOME}/${INSTALL_DIR}/bin" >> ${GITHUB_ENV}
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/${INSTALL_DIR}/lib" >> ${GITHUB_ENV}
echo "DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${HOME}/${INSTALL_DIR}/lib:$INSTALL_DIR/bin" >> ${GITHUB_ENV}
- name: Checkout Carolina
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Install Carolina and make wheel
run: |
python --version
arch_ver=$(uname -m)
# hint regarding architecture to avoid universal wheel generated
export _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-$arch_ver"
export ARCHFLAGS="-arch $arch_ver"
pip install delocate
python -m pip install .
PYTHON_VERSION_TRIM=$(echo ${{ matrix.python-version }} | tr -d ".")
echo $PYTHON_VERSION_TRIM
carolina_cpython_lib=carolina.cpython-$PYTHON_VERSION_TRIM-darwin.so
site_packages_dir=$(python -c "import site; print(site.getsitepackages()[0])")
carolina_so_path=$(find "$site_packages_dir" -name "$carolina_cpython_lib")
fortran_dylib_path=$(find /usr -name "libgfortran.dylib" | head -n 1)
echo "found site packages @ $site_packages_dir"
echo "found $carolina_cpython_lib @ $carolina_so_path"
echo "found libgfortran.dylib @ $fortran_dylib_path"
fortran_dylib_dir=$(dirname "$fortran_dylib_path")
install_lib_dir=$HOME/$INSTALL_DIR/lib
BREW_CELLAR=$(brew --prefix)/Cellar
libgccpath=$(dirname $(find $BREW_CELLAR/gcc -name libgcc_s.1.1.dylib 2>/dev/null | head -n 1))
libdakotapath=$(dirname $(find ${HOME}/${INSTALL_DIR}/lib -name libdakota_util.dylib 2>/dev/null | head -n 1))
echo "libgccpath=$libgccpath"
echo "libdakotapath=$libdakotapath"
install_name_tool -add_rpath "$libgccpath" "$carolina_so_path"
install_name_tool -add_rpath "${HOME}/${INSTALL_DIR}/lib" "$carolina_so_path"
mkdir /tmp/carolina_dist
mkdir /tmp/carolina_dist_unfixed
echo "which pip: $(which pip)"
echo "which python: $(which python)"
echo "$(python -c "import platform; mac_version=platform.mac_ver(); print('macOS version from py: '+mac_version[0])")"
pip debug -v|grep -v macosx_10_
pip install build
python -m build --wheel . --outdir /tmp/carolina_dist_unfixed
echo "Pip list ...... "
pip list | grep carolina
echo $carolina_so_path
otool -l $carolina_so_path
echo "Finding missing dylibs"
ls -lh /tmp/carolina_dist_unfixed
pv=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
unfixed_wheel_path=$(find /tmp/carolina_dist_unfixed -name "carolina*$pv*whl")
echo "Found Carolina wheel at $unfixed_wheel_path"
# Avoid MacOS security features prohibiting setting DYLD_LIBRARY_PATH
# ref issue: https://github.com/pypa/cibuildwheel/issues/816
EXTENDED_DYLD_LIBRARY_PATH="${libgccpath}:${HOME}/${INSTALL_DIR}/lib:$INSTALL_DIR/bin"
DYLD_LIBRARY_PATH=${EXTENDED_DYLD_LIBRARY_PATH} delocate-listdeps $unfixed_wheel_path
DYLD_LIBRARY_PATH=${EXTENDED_DYLD_LIBRARY_PATH} delocate-wheel -w /tmp/carolina_dist -v $unfixed_wheel_path
echo "Output new carolina wheel to /tmp/carolina_dist"
ls -lh /tmp/carolina_dist
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
id: cache-carolina_wheel
with:
name: ${{ matrix.os }}_py-${{ matrix.python-version }}_wheel
path: /tmp/carolina_dist/carolina*
tests:
needs: build_dependencies
if: ${{ needs.build_dependencies.result != 'failed' }}
name: "tests_${{ matrix.os }}_py-${{ matrix.python-version }}"
env:
ERT_SHOW_BACKTRACE: ${{ inputs.ERT_SHOW_BACKTRACE }}
NO_PROJECT_RES: ${{ inputs.NO_PROJECT_RES }}
strategy:
fail-fast: false
matrix:
python-version: [ '3.12', '3.13', '3.14' ]
os: [ 'macos-15' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
setup.py
pyproject.toml
- name: Download Carolina artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: /tmp/artifacts
- name: Find the Carolina wheel
run: |
python --version
pip install -U pip
pyver_nodot=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
arch_ver=$(uname -m)
wheel_path=$(find /tmp/artifacts/${{ matrix.os }}_py-${{ matrix.python-version }}_wheel -name "carolina*-cp$pyver_nodot*-cp$pyver_nodot*macos*$arch_ver*whl")
echo "Found Carolina wheel at $wheel_path"
pip install $wheel_path
- name: Test Carolina
run: |
python --version
pip install pytest numpy
python -m pytest tests -sv