Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: "Build and Test pyEXP on Mac"

on:
push:
branches:
- '*'
pull_request:
branches:
- main
- devel
jobs:
exp:
strategy:
matrix:
os: [macos-latest]

name: "Test pyEXP Build on Mac"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install EXP dependencies (Mac)
run: |
brew install eigen fftw open-mpi hdf5 libomp

echo CC=mpicc >> $GITHUB_ENV
echo CXX=mpicxx >> $GITHUB_ENV
echo OMPI_CC="clang" >> $GITHUB_ENV
echo OMPI_CXX="clang++" >> $GITHUB_ENV

echo OMP_HOME=${HOMEBREW_PATH}/opt/libomp/ >> $GITHUB_ENV
echo LDFLAGS="-L${OMP_HOME}/lib" >> $GITHUB_ENV
echo CPPFLAGS="-I${OMP_HOME}/include" >> $GITHUB_ENV

- name: Build EXP
run: |
# Get Python version info
PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PYTHON_EXEC=$(which python)
PYTHON_LIBRARY_PATH=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")

# Set Python library path based on OS
if [[ "$RUNNER_OS" == "macOS" ]]; then
PYTHON_LIBRARY=${PYTHON_LIBRARY_PATH}/libpython${PYTHON_VERSION}.dylib
else
PYTHON_LIBRARY=${PYTHON_LIBRARY_PATH}/libpython${PYTHON_VERSION}.so
fi

cmake -G Ninja -B build \
-DCMAKE_INSTALL_RPATH=$PWD/install/lib \
--install-prefix $PWD/install \
-DENABLE_NBODY=YES \
-DENABLE_PYEXP=YES \
-DDISABLE_OPENMP_COMPILE_FLAGS=YES \
-DPYTHON_EXECUTABLE=${PYTHON_EXEC} \
-DPYTHON_LIBRARY=${PYTHON_LIBRARY} \
-DOpenMP_CXX_INCLUDE_DIR=${OMP_HOME}/include \
-DOpenMP_C_INCLUDE_DIR=${OMP_HOME}/include

# Build and install EXP
cmake --build build
cmake --install build

# Add the pyEXP dir as a pyEXP.pth file in Python site-packages:
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
echo "$PWD/install/lib/python${PYTHON_VERSION}/site-packages" > "${SITE_PACKAGES}/pyEXP.pth"

- name: CTest Quick
run: ctest --output-on-failure -L quick

- name: Test pyEXP
run: |
python -c "import pyEXP; print('pyEXP successfully imported')"
4 changes: 3 additions & 1 deletion expui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ add_executable(testread testread.cc)
foreach(program ${bin_PROGRAMS})
target_link_libraries(${program} expui exputil ${common_LINKLIB})
target_include_directories(${program} PUBLIC ${common_INCLUDE})
target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS})
if(NOT DISABLE_OPENMP_COMPILE_FLAGS)
target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS})
endif()
install(TARGETS ${program} DESTINATION bin)
endforeach()
4 changes: 3 additions & 1 deletion pyEXP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ pybind11_add_module(pyEXP PyWrappers.cc CoefWrappers.cc
ParticleReaderWrappers.cc MSSAWrappers.cc EDMDWrappers.cc)
target_link_libraries(pyEXP PUBLIC expui exputil ${common_LINKLIB})
target_include_directories(pyEXP PUBLIC ${common_INCLUDE})
target_compile_options(pyEXP PUBLIC ${OpenMP_CXX_FLAGS})
if(NOT DISABLE_OPENMP_COMPILE_FLAGS)
target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS})
endif()
get_target_property(cxxflags pyEXP COMPILE_OPTIONS)
message("The project has set the following flags: ${cxxflags}")

Expand Down
Loading