Skip to content

Commit

Permalink
Merge pull request cyclus#1814 from cyclus/macos-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke authored Oct 3, 2024
2 parents ca91db9 + c2f15f6 commit f7a42f1
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.github/workflows/changelog_test.yml'
- '.github/workflows/code_coverage.yml'
- '.github/workflows/rocky_build_test.yml'
- '.github/workflows/macos_build_test.yml'
- 'doc/**'
- 'CHANGELOG.rst'
push:
Expand All @@ -19,6 +20,7 @@ on:
- '.github/workflows/changelog_test.yml'
- '.github/workflows/code_coverage.yml'
- '.github/workflows/rocky_build_test.yml'
- '.github/workflows/macos_build_test.yml'
- 'doc/**'
- 'CHANGELOG.rst'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.github/workflows/publish_release.yml'
- '.github/workflows/changelog_test.yml'
- '.github/workflows/rocky_build_test.yml'
- '.github/workflows/macos_build_test.yml'
- 'doc/**'
- 'CHANGELOG.rst'
push:
Expand Down
97 changes: 97 additions & 0 deletions .github/workflows/macos_build_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: MacOS Build/Test Cyclus

on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
paths-ignore:
- ".github/workflows/build_test.yml"
- ".github/workflows/publish_latest.yml"
- ".github/workflows/publish_release.yml"
- ".github/workflows/changelog_test.yml"
- ".github/workflows/code_coverage.yml"
- ".github/workflows/rocky_build_test.yml"
- "doc/**"
- "CHANGELOG.rst"
push:
paths-ignore:
- ".github/workflows/build_test.yml"
- ".github/workflows/publish_latest.yml"
- ".github/workflows/publish_release.yml"
- ".github/workflows/changelog_test.yml"
- ".github/workflows/code_coverage.yml"
- ".github/workflows/rocky_build_test.yml"
- "doc/**"
- "CHANGELOG.rst"

jobs:
build-test-conda:
strategy:
fail-fast: false
matrix:
macos_versions: [
macos-12,
macos-13,
macos-14,
]

runs-on: ["${{ matrix.macos_versions }}"]

steps:
- name: Setup XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest

- name: Checkout Cyclus
uses: actions/checkout@v4

- name: --slow flag if on ARM
if: ${{ matrix.macos_versions == 'macos-14' }}
run: |
echo "SLOW_FLAG=--slow" >> "$GITHUB_ENV"
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: "latest"
conda-solver: "libmamba"
auto-update-conda: true
channels: conda-forge

- name: Build and Test Cyclus
id: build-cyclus
shell: bash -el {0}
run: |
mamba install -y \
compilers \
cmake \
make \
git \
glib \
libxml2 \
libxmlpp-4.0 \
liblapack \
pkg-config \
coincbc \
boost-cpp \
hdf5 \
sqlite \
pcre \
setuptools \
pytest \
pytables \
pandas \
jinja2 \
cython \
websockets \
pprintpp \
pip
export CC=$CONDA_PREFIX/bin/clang
export CXX=$CONDA_PREFIX/bin/clang++
export CPP=$CONDA_PREFIX/bin/clang-cpp
mkdir -p $(python3 -m site --user-site)
python3 install.py -j 3 --allow-milps ${SLOW_FLAG}
export PATH=$HOME/.local/bin:$PATH
cyclus_unit_tests
cd tests && python3 -m pytest
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Since last release
* Added ``doxygen-awesome-css`` to doxygen docs for style (#1787)
* Added installation of files for building docs to share/cyclus/doc (#1807)
* New packaging strategies uniform and normal (#1813)
* Add CI support for MacOS 12, 13, and 14 (#1814)

**Changed:**

Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ IF(NOT CYCLUS_DOC_ONLY)
set(suffix ".dll")
set(dynamicloadlib "windows_helper_functions.h")
ELSEIF(APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup -flat_namespace")
set(suffix ".dylib")
set(dynamicloadlib "unix_helper_functions.h")
ELSE()
Expand Down Expand Up @@ -280,9 +280,6 @@ IF(NOT CYCLUS_DOC_ONLY)
endif()
message("-- PYTHON_EXECUTABLE: ${Python3_EXECUTABLE}")
message("-- PYTHON_SITE_PACKAGES: ${PYTHON_SITE_PACKAGES}")
IF (NOT APPLE)
set(LIBS ${LIBS} ${Python3_LIBRARIES})
ENDIF (NOT APPLE)

# Include the CMake script UseCython.cmake. This defines add_cython_module().
# Instruction for use can be found at the top of cmake/UseCython.cmake.
Expand Down
15 changes: 14 additions & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,21 @@ flags:
- the cmake prefix path for use with FIND_PACKAGE, FIND_PATH, FIND_PROGRAM, or FIND_LIBRARY macros

* - ``--build-type BUILD_TYPE``
- change the CMAKE_BUILD_TYPE
- change the CMAKE_BUILD_TYPE

* - ``--data-model-version``
- sets the data model version number

* - ``--code_coverage``
- Enable code coverage analysis using gcov/lcov

* - ``--fast``
- Will try to compile from assembly, if possible (default). This is faster than compiling from source.

* - ``--slow``
- Will NOT try to compile from assembly, if possible. This is slower as it must compile from source.
**This is required to build on Apple Silicon**

* - ``-D VAR``
- set environment variable(s).

Expand Down
3 changes: 0 additions & 3 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ INCLUDE_DIRECTORIES(BEFORE ${CYCLUS_CORE_INCLUDE_DIRS})
SET(CYCLUS_SOURCE ${CYCLUS_SOURCE}
cyclus.cc
)
IF (APPLE)
SET(LIBS ${Python3_LIBRARIES} ${LIBS})
ENDIF(APPLE)

ADD_EXECUTABLE(cyclus_cli ${CYCLUS_SOURCE})
set_target_properties(cyclus_cli PROPERTIES OUTPUT_NAME cyclus)
Expand Down
4 changes: 4 additions & 0 deletions cmake/UseCyclus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ macro(cyclus_platform)
set(_plat "${_plat}-gnu")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(_plat "${_plat}-clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(_plat "${_plat}-clang")
else()
set(_plat "${_plat}-NOTFOUND")
endif()
Expand Down Expand Up @@ -407,6 +409,8 @@ macro(fast_compile _srcname _gnuflags _clangflags _otherflags)
set_source_files_properties("${_filename}" PROPERTIES COMPILE_FLAGS "${_gnuflags}")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_source_files_properties("${_filename}" PROPERTIES COMPILE_FLAGS "${_clangflags}")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set_source_files_properties("${_filename}" PROPERTIES COMPILE_FLAGS "${_clangflags}")
else()
set_source_files_properties("${_filename}" PROPERTIES COMPILE_FLAGS "${_otherflags}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/UseCython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function( cython_add_module _name )
include_directories( ${Python3_INCLUDE_DIRS} )
Python3_add_library( ${_name} ${generated_file} ${other_module_sources} )
if( APPLE )
set_target_properties( ${_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" )
set_target_properties( ${_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup -flat_namespace" )
else()
target_link_libraries( ${_name} PRIVATE ${Python3_LIBRARIES} )
endif()
Expand Down
5 changes: 3 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def main():
default='Release')

parser.add_argument('--data-model-version', dest='data_model_version', default=None,
help='Sets the core version number.')
help='Sets the data model version number.')

parser.add_argument('-D', metavar='VAR', action='append',
help='Set enviornment variable(s).')
Expand All @@ -210,7 +210,8 @@ def main():
parser.add_argument('--slow', dest='fast',
action='store_false', help="Will NOT try to compile "
"from assembly, if possible. This is slower as it "
"must compile from source.")
"must compile from source. **This is required to "
"build on Apple Silicon**")

args = parser.parse_args()
# modify roots as needed
Expand Down
14 changes: 10 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ if(Cython_FOUND)
TARGETS ${name}
LIBRARY DESTINATION lib
)
INSTALL(
TARGETS ${name}
LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}
# Add symlinks to PYTHON_SITE_PACKAGES so python can find our cython modules
# Python will only import libraries with .so extensions
# so we hardcode the symlink with .so even on APPLE
INSTALL(CODE "
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_INSTALL_PREFIX}/lib/${name}${suffix}
${PYTHON_SITE_PACKAGES}/${name}.so
)"
)

copy_when_diff(${_generated_h} ${_h_file})
Expand Down Expand Up @@ -251,7 +257,7 @@ SET_TARGET_PROPERTIES(cyclus
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)

TARGET_LINK_LIBRARIES(cyclus dl ${LIBS})
TARGET_LINK_LIBRARIES(cyclus dl ${LIBS} Python3::Python)

INSTALL(
TARGETS cyclus
Expand Down
2 changes: 1 addition & 1 deletion src/toolkit/res_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ResMap {
}

/// Whether quantity_ should be recomputed or not.
bool dirty_quantity_;
mutable bool dirty_quantity_;

/// Current total quantity of all resources in the mapping.
double quantity_;
Expand Down
10 changes: 8 additions & 2 deletions tests/test_env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests Python wrapping on Env object."""
from __future__ import print_function, unicode_literals


import sys
from cyclus import lib

ENV = lib.Env()
Expand All @@ -22,7 +22,13 @@ def test_paths():
assert isinstance(path, str)
assert len(ENV.env_delimiter) > 0
assert len(ENV.path_delimiter) > 0
assert len(ENV.find_module('libagents.so')) > 0
if sys.platform.startswith('darwin'):
ext = '.dylib'
elif sys.platform.startswith('linux'):
ext = '.so'
else: # we are not on a supported platform, make failing assertion
assert "platform" == "darwin or linux"
assert len(ENV.find_module(f'libagents{ext}')) > 0


def test_nuc_data():
Expand Down

0 comments on commit f7a42f1

Please sign in to comment.