diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml new file mode 100644 index 000000000..368c6775a --- /dev/null +++ b/.github/workflows/build-mac.yml @@ -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')" diff --git a/expui/CMakeLists.txt b/expui/CMakeLists.txt index 25f438d0a..4472dbaa7 100644 --- a/expui/CMakeLists.txt +++ b/expui/CMakeLists.txt @@ -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() diff --git a/pyEXP/CMakeLists.txt b/pyEXP/CMakeLists.txt index dc8cebf0e..be04e98ae 100644 --- a/pyEXP/CMakeLists.txt +++ b/pyEXP/CMakeLists.txt @@ -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}")