Skip to content

Build medpython (macOS) #11

Build medpython (macOS)

Build medpython (macOS) #11

Workflow file for this run

name: Build medpython (macOS)
on:
workflow_dispatch:
jobs:
build_mac_wheels:
name: Build on macOS
runs-on: macos-15-intel
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12' # Adjust to your needed version
# --- 1. RESTORE CACHE (Check if it exists) ---
- name: Restore Boost Cache
id: cache-boost
uses: actions/cache/restore@v4
with:
path: ./Boost
key: boost-1.89.0-macos-x86_64
# --- BUILD BOOST (Only runs if cache miss) ---
- name: Build Boost 1.89.0
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
# 1. Download
VERSION=1.89.0
VERSION_UNDERSCORE=$(echo ${VERSION} | sed 's/\./_/g')
curl -L -o boost_${VERSION_UNDERSCORE}.tar.bz2 https://archives.boost.io/release/${VERSION}/source/boost_${VERSION_UNDERSCORE}.tar.bz2
# 2. Extract
tar -xjf boost_${VERSION_UNDERSCORE}.tar.bz2
# 3. Setup Directories
WORK_BUILD_FOLDER=$(pwd)
cd boost_${VERSION_UNDERSCORE}
# 4. Bootstrap
./bootstrap.sh
# 5. Build Static (macOS adaptation)
# Note: b2 automatically detects clang on macOS
./b2 cxxflags="-march=x86-64 -fPIC" \
link=static \
variant=release \
threading=multi \
pch=off \
-j$(sysctl -n hw.ncpu) \
--stagedir="${WORK_BUILD_FOLDER}/Boost" \
--with-program_options --with-system --with-regex --with-filesystem
# 6. Build Shared (for MES tools)
./b2 cxxflags="-march=x86-64 -fPIC" \
link=shared \
variant=release \
threading=multi \
pch=off \
-j$(sysctl -n hw.ncpu) \
--stagedir="${WORK_BUILD_FOLDER}/Boost" \
--with-program_options --with-system --with-regex --with-filesystem
# 7. Organize Headers
mkdir -p ${WORK_BUILD_FOLDER}/Boost/include
cp -r ${WORK_BUILD_FOLDER}/boost_${VERSION_UNDERSCORE}/boost ${WORK_BUILD_FOLDER}/Boost/include/
- name: Save Boost Cache
if: steps.cache-boost.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ./Boost
key: boost-1.89.0-macos-x86_64
# --- SETUP ENVIRONMENT VARIABLES ---
- name: Set BOOST_ROOT
run: echo "BOOST_ROOT=$(pwd)/Boost" >> $GITHUB_ENV
# --- BUILD PYTHON PACKAGE ---
- name: Build MedPython Package
run: |
# Check we have the Boost Root
brew install libomp
echo "Using Boost at: $BOOST_ROOT"
cd Internal/MedPyExport/generate_binding
# Install dependencies (if you have a requirements.txt, run it here)
pip install numpy setuptools cmake "swig<4.3" pandas plotly
LIBOMP_PREFIX=$(brew --prefix libomp)
export CFLAGS="-Xpreprocessor -fopenmp -I$LIBOMP_PREFIX/include $CFLAGS"
export CXXFLAGS="-Xpreprocessor -fopenmp -I$LIBOMP_PREFIX/include $CXXFLAGS"
export LDFLAGS="-lomp -L$LIBOMP_PREFIX/lib $LDFLAGS"
# Run the installation
export CMAKE_ARGS="-DBoost_NO_BOOST_CMAKE=ON"
pip install . -vv --no-build-isolation
- name: Test MedPython
run: |
python -c 'import med'