From a2857ce96f8d15f6f09c9e7641790ef387cc1c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Sat, 9 Dec 2023 14:59:23 +0100 Subject: [PATCH 1/4] ci: rename ci.yml to ubuntu.yml --- .github/workflows/{ci.yml => ubuntu.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci.yml => ubuntu.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ubuntu.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/ubuntu.yml From 9f94669b0a3908e9b73850c0177a6d4e73c705f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Sat, 9 Dec 2023 15:00:14 +0100 Subject: [PATCH 2/4] cmake: link pycsdiff with PythonX::Module ... to fix the following build error on macOS: ``` [ 86%] Linking CXX shared library pycsdiff_py3/pycsdiff.dylib ld: Undefined symbols: _PyUnicode_FromStringAndSize, referenced from: boost::python::detail::caller_arity<2u>::impl, std::__1::allocator> (*)(std::__1::basic_string, std::__1::allocator> const&, std::__1::basic_string, std::__1::allocator> const&), boost::python::default_call_policies, boost::mpl::vector3, std::__1::allocator>, std::__1::basic_string, std::__1::allocator> const&, std::__1::basic_string, std::__1::allocator> const&>>::operator()(_object*, _object*) in pycsdiff.cc.o boost::python::objects::caller_py_function_impl, std::__1::allocator> (*)(), boost::python::default_call_policies, boost::mpl::vector1, std::__1::allocator>>>>::operator()(_object*, _object*) in pycsdiff.cc.o _PyUnicode_Type, referenced from: boost::python::detail::converter_target_type, std::__1::allocator> const&>>::get_pytype() in pycsdiff.cc.o __Py_Dealloc, referenced from: boost::python::api::slice_nil::~slice_nil() in pycsdiff.cc.o void boost::python::def, std::__1::allocator> (*)(std::__1::basic_string, std::__1::allocator> const&, std::__1::basic_string, std::__1::allocator> const&)>(char const*, std::__1::basic_string, std::__1::allocator> (*)(std::__1::basic_string, std::__1::allocator> const&, std::__1::basic_string, std::__1::allocator> const&)) in pycsdiff.cc.o void boost::python::def, std::__1::allocator> (*)()>(char const*, std::__1::basic_string, std::__1::allocator> (*)()) in pycsdiff.cc.o boost::python::api::object::~object() in pycsdiff.cc.o __Py_NoneStruct, referenced from: __GLOBAL__sub_I_pycsdiff.cc in pycsdiff.cc.o clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 565f1f32..7cba398a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with csdiff. If not, see . -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.15) project(csdiff CXX) enable_testing() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a13d9032..b8b5a86e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,10 +106,9 @@ macro(build_pycsdiff version) "The pycsdiff module will be built!") add_library(pycsdiff_py${version} SHARED pycsdiff.cc) - target_include_directories(pycsdiff_py${version} SYSTEM - PRIVATE ${Python${version}_INCLUDE_DIRS}) target_link_libraries(pycsdiff_py${version} - PRIVATE ${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY}) + PRIVATE ${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY} + Python${version}::Module) # set correct name so that `python -c 'import pycsdiff' works` set_target_properties(pycsdiff_py${version} PROPERTIES From 87e709aa1c070f55e45807ea70a53afd5eadcf5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Sat, 9 Dec 2023 15:01:33 +0100 Subject: [PATCH 3/4] cmake: declare the pycsdiff target as a MODULE library ... to mark the intent that it is meant to be used by `dlopen` only. Consequently, this forces the library to always use the `.so` suffix which fixes the following test failure on macOS because Python ignores shared libraries with the native `.dylib` suffix. ``` pycsdiff_py3......................................***Failed 0.02 sec Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'pycsdiff' ``` --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8b5a86e..59cfac49 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,7 +105,7 @@ macro(build_pycsdiff version) message(STATUS "Python ${version} binding enabled. " "The pycsdiff module will be built!") - add_library(pycsdiff_py${version} SHARED pycsdiff.cc) + add_library(pycsdiff_py${version} MODULE pycsdiff.cc) target_link_libraries(pycsdiff_py${version} PRIVATE ${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY} Python${version}::Module) From 56ceca806402b7b9d5d61c82825dc7ac708baaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Sun, 10 Dec 2023 10:36:03 +0100 Subject: [PATCH 4/4] ci: add a macOS GitHub Actions workflow --- .github/workflows/macos.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/macos.yml diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..6a253e1a --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,34 @@ +--- +name: macOS CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + ubuntu: + name: macOS ${{ matrix.version }} (${{ matrix.compiler }}) + strategy: + fail-fast: false + matrix: + compiler: [clang++] + version: [latest] + + runs-on: macos-${{ matrix.version }} + env: + CXX: ${{ matrix.compiler }} + CXXFLAGS: -Werror + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + brew upgrade + brew install boost boost-python3 help2man + + - name: Build and check + run: make distcheck