Skip to content

Commit

Permalink
Resolve Unit Test Failures
Browse files Browse the repository at this point in the history
- Upgrade Boost action to use Conan V2 and Boost 1.85;
- Lock Numpy to V1 due to compatibility issues with Boost when
  using Numpy V2 (boostorg/python#431);
- Default example to C++ STD 17 to prevent compilation errors on macOS.
  • Loading branch information
buddly27 committed Aug 1, 2024
1 parent c60d978 commit 0f75449
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 55 deletions.
90 changes: 43 additions & 47 deletions .github/actions/install-boost-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,64 @@ name: install-boost
description: "Install Boost "

inputs:
platform:
description: "Indicate the identifier of the platform"

python:
description: "Path to python executable"
description: "Python version targeted"

path:
description: "Path to install CMake config into"

runs:
using: composite
steps:
- name: Install conan
shell: bash
run: |
python3 -m pip install conan==1.*
conan profile new default --detect
conan profile show default
- name: Setup compiler (Linux only)
shell: bash
if: ${{ inputs.platform == 'ubuntu' }}
run: |
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile show default
python3 -m pip install --upgrade pip
python3 -m pip install conan==2.*
conan profile detect
conan profile show
- name: Install numpy
shell: bash
# For some reason, boost python cannot be installed without numpy
# https://github.com/conan-io/conan-center-index/issues/10953
run: ${{ inputs.python }} -m pip install numpy
run: python3 -m pip install numpy==1.*

- name: Install Boost Python
working-directory: ${{ inputs.path }}
shell: bash
run: |
conan install boost/1.80.0@ \
--options=boost:without_python=False \
--options=boost:without_atomic=True \
--options=boost:without_chrono=True \
--options=boost:without_container=True \
--options=boost:without_context=True \
--options=boost:without_contract=True \
--options=boost:without_coroutine=True \
--options=boost:without_date_time=True \
--options=boost:without_exception=True \
--options=boost:without_fiber=True \
--options=boost:without_filesystem=True \
--options=boost:without_graph=True \
--options=boost:without_iostreams=True \
--options=boost:without_json=True \
--options=boost:without_locale=True \
--options=boost:without_log=True \
--options=boost:without_math=True \
--options=boost:without_nowide=True \
--options=boost:without_program_options=True \
--options=boost:without_random=True \
--options=boost:without_regex=True \
--options=boost:without_serialization=True \
--options=boost:without_stacktrace=True \
--options=boost:without_system=True \
--options=boost:without_test=True \
--options=boost:without_thread=True \
--options=boost:without_timer=True \
--options=boost:without_type_erasure=True \
--options=boost:without_wave=True \
--options=boost:python_executable=${{ inputs.python }} \
--generator=cmake_find_package \
conan install \
--requires boost/1.85.0@ \
--options=boost/*:without_python=False \
--options=boost/*:without_atomic=True \
--options=boost/*:without_chrono=True \
--options=boost/*:without_container=True \
--options=boost/*:without_context=True \
--options=boost/*:without_contract=True \
--options=boost/*:without_coroutine=True \
--options=boost/*:without_date_time=True \
--options=boost/*:without_exception=True \
--options=boost/*:without_fiber=True \
--options=boost/*:without_filesystem=True \
--options=boost/*:without_graph=True \
--options=boost/*:without_iostreams=True \
--options=boost/*:without_json=True \
--options=boost/*:without_locale=True \
--options=boost/*:without_log=True \
--options=boost/*:without_math=True \
--options=boost/*:without_nowide=True \
--options=boost/*:without_program_options=True \
--options=boost/*:without_random=True \
--options=boost/*:without_regex=True \
--options=boost/*:without_serialization=True \
--options=boost/*:without_stacktrace=True \
--options=boost/*:without_system=False \
--options=boost/*:without_test=True \
--options=boost/*:without_thread=True \
--options=boost/*:without_timer=True \
--options=boost/*:without_type_erasure=True \
--options=boost/*:without_wave=True \
--options=boost/*:python_version=${{ inputs.python }} \
--generator=CMakeDeps \
--build=missing
13 changes: 9 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ jobs:
- name: Install Boost Python
uses: ./.github/actions/install-boost-python
with:
platform: ${{ matrix.os }}
python: $(which python)
python: ${{ matrix.python }}
path: ${{ runner.temp }}

- name: Install pytest + pytest-cmake
run: pip install . pytest==${{ matrix.pytest }}.*
run: python3 -m pip install . pytest==${{ matrix.pytest }}.*

- name: Build Example
shell: bash
run: |
cmake --version
cmake -D "CMAKE_MODULE_PATH:FILEPATH=${{ github.workspace }}" -S ./example -B ./build
cmake \
-D "CMAKE_BUILD_TYPE=Release" \
-D "Boost_ROOT=${{ runner.temp }}" \
-S ./example \
-B ./build
cmake --build ./build --config Release
- name: Run Tests
Expand Down
10 changes: 6 additions & 4 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ cmake_minimum_required(VERSION 3.20)

project(Example)

find_package(Python COMPONENTS Interpreter Development REQUIRED)
set(_py_version ${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
mark_as_advanced(_py_version)
if (NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "Default C++ standard")
endif()

if (WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()

find_package(Boost 1.70.0 COMPONENTS "python${_py_version}" REQUIRED)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
find_package(Boost 1.70.0 REQUIRED)

if (NOT TARGET Boost::python)
set(_py_version ${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
add_library(Boost::python ALIAS "Boost::python${_py_version}")
endif()

Expand Down

0 comments on commit 0f75449

Please sign in to comment.