Skip to content

Commit

Permalink
Debug print and remove most work in workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed May 21, 2024
1 parent de4b066 commit 8fa2ad4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 321 deletions.
63 changes: 1 addition & 62 deletions .github/workflows/bundle_with_dakota_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8','3.9','3.10','3.11','3.12']
python-version: ['3.8']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
Expand All @@ -48,69 +48,8 @@ jobs:
key: carolina_deps_${{ matrix.os }}_python-${{ matrix.python-version }}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}
path: ./deps_build

- name: Build Boost & Dakota
if: steps.cache-package-check.outputs.cache-hit != 'true'
uses: docker://quay.io/pypa/manylinux2014_x86_64
env:
PYTHON_VERSION: ${{ matrix.python-version }}
BOOST_VERSION: ${{ inputs.BOOST_VERSION }}
DAKOTA_VERSION: ${{ inputs.DAKOTA_VERSION }}
with:
entrypoint: /bin/bash
args: '-c "sh dakota_manylinux_install_files/build_deps_gha.sh ${{ matrix.python-version }}"'

- uses: actions/cache/save@v4
if: steps.cache-package-check.outputs.cache-hit != 'true'
id: cache-package-store
with:
key: carolina_deps_${{ matrix.os }}_python-${{ matrix.python-version }}_boost-${{ inputs.BOOST_VERSION }}_dakota-${{ inputs.DAKOTA_VERSION }}
path: ./deps_build

- name: Build Linux Wheel
uses: docker://quay.io/pypa/manylinux2014_x86_64
env:
PYTHON_VERSION: ${{ matrix.python-version }}
BOOST_VERSION: ${{ inputs.BOOST_VERSION }}
DAKOTA_VERSION: ${{ inputs.DAKOTA_VERSION }}
with:
entrypoint: /bin/bash
args: '-c "sh dakota_manylinux_install_files/build_wheels_gha.sh ${{ matrix.python-version }}"'

- name: Checkout Carolina
uses: actions/checkout@v4
with:
fetch-depth: 0
path: carolina-main

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set up python venv
run: python -m venv othervenv

- name: Install Carolina from wheel
run: |
source othervenv/bin/activate
pyver_nodot=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
wheel_path=$(find carolina_dist -name "carolina*$pyver_nodot*whl")
echo "Found Carolina wheel at $wheel_path"
pip install $wheel_path
- name: Test Carolina
run: |
source othervenv/bin/activate
pip install pytest
cd carolina-main/tests
python -m pytest .
cd -
- name: Upload wheel as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} Python ${{ matrix.python-version }} wheel
path: |
carolina_dist/*
trace/*
271 changes: 12 additions & 259 deletions .github/workflows/bundle_with_dakota_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
fail-fast: true
matrix:
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
python-version: [ '3.8', '3.11', '3.12' ]
os: [ 'macos-14', 'macos-14-large', 'macos-13' ]
python-version: [ '3.11' ]
os: [ 'macos-14' ]
exclude:
- os: 'macos-14'
python-version: '3.8'
Expand Down Expand Up @@ -68,6 +68,10 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems

- name: Install Homebrew gcc
if: steps.cache.outputs.cache-hit != 'true'
run: brew install gcc

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand All @@ -82,267 +86,16 @@ jobs:
which python
which pip
python -c "import platform; mac_version=platform.mac_ver(); print('macOS version: '+mac_version[0])"
- uses: actions/cache@v4
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: Install dependencies
if: steps.cache-package.outputs.cache-hit != 'true'
run: |
python -m pip install -U pip
python -m pip install numpy
- 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://boostorg.jfrog.io/artifactory/main/release/${{ inputs.BOOST_VERSION }}/source/boost_${BOOST_VERSION_UNDERSCORES}.tar.gz
tar -xf boost_${BOOST_VERSION_UNDERSCORES}.tar.gz
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: |
python --version
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")
echo "FORTRAN_FULLPATH:"
echo $FORTRAN_FULLPATH
FORTRAN_PATH=$(dirname "$FORTRAN_FULLPATH")
echo "FORTRAN_PATH:"
echo $FORTRAN_PATH
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 (v6.19) could contain corrupt Eigen3Config.cmake file
if [ ! -f $EIGEN_CMAKE_PATH/Eigen3Config.cmake ]; then
echo "Fetching alternative source to replace corrupted Eigen cmake file.."
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 -qq dakota-${{ inputs.DAKOTA_VERSION }}-public-src-cli.zip
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
mkdir -p build
cd build
cmake \
-DCMAKE_CXX_STANDARD=14 \
-DBUILD_SHARED_LIBS=ON \
-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@v4
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@v4
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@v4
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-11.0-$arch_ver"
export ARCHFLAGS="-arch $arch_ver"
target_version=$(sw_vers --productVersion | cut -d . -f 1)
# the arm64 builds require deployment targets >= 13.0
if [ "$arch_ver" == "arm64" ]; then
export MACOSX_DEPLOYMENT_TARGET="${target_version}.0"
fi
pip install delocate==0.10.7
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@v4
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.8', '3.11', '3.12' ]
os: [ 'macos-14', 'macos-14-large', 'macos-13' ]
exclude:
- os: 'macos-14'
python-version: '3.8'
- os: 'macos-14-large'
python-version: '3.8'

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
setup.py
pyproject.toml
- name: Download Carolina artifact
uses: actions/download-artifact@v4
with:
path: /tmp/artifacts

- name: Find the Carolina wheel
run: |
python --version
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
gcc --version
gfortran --version

0 comments on commit 8fa2ad4

Please sign in to comment.