From 58adf984a02301f7d2b878ae930e5bb5181929dd Mon Sep 17 00:00:00 2001 From: Zach Nation Date: Thu, 1 Jul 2021 11:44:10 -0700 Subject: [PATCH] fix: compatibility with Ubuntu 18.04 (#1232) Fixes compatibility with Ubuntu 18.04 by: * Downgrading our build image from 20.04 to 18.04 * Fall back to using for compatibility with the libstdc++ on 18.04, with corresponding linking to stdc++fs --- .gitlab-ci.yml | 10 +++++----- CMakeLists.txt | 6 ++++++ docker/Dockerfile-coremltools-linux | 2 +- modelpackage/src/ModelPackage.cpp | 10 ++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69a91fdd3..c865c5be4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,25 +40,25 @@ check_python_flake8: build_wheel_linux_py35: <<: *build_linux - image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-20.04:1.0.2 + image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-18.04:1.0.0 variables: PYTHON: "3.5" build_wheel_linux_py36: <<: *build_linux - image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-20.04:1.0.2 + image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-18.04:1.0.0 variables: PYTHON: "3.6" build_wheel_linux_py37: <<: *build_linux - image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-20.04:1.0.2 + image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-18.04:1.0.0 variables: PYTHON: "3.7" build_wheel_linux_py38: <<: *build_linux - image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-20.04:1.0.2 + image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-18.04:1.0.0 variables: PYTHON: "3.8" @@ -214,7 +214,7 @@ build_documentation: tags: - docker stage: test - image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-20.04:1.0.0 + image: registry.gitlab.com/zach_nation/coremltools/build-image-ubuntu-18.04:1.0.0 script: - export PATH=$PATH:/opt/anaconda/bin/ - bash -e scripts/build_docs.sh --wheel-path=${WHEEL_PATH} --python=${PYTHON} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7098e3581..f3ef18924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,12 @@ target_link_libraries(modelpackage libprotobuf ) +if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) + target_link_libraries(modelpackage + stdc++fs + ) +endif() + if (APPLE) # Allow Python to be found at runtime instead of compile/link time # This is apparently the default on Linux diff --git a/docker/Dockerfile-coremltools-linux b/docker/Dockerfile-coremltools-linux index 5d1f853d3..eb013ed32 100644 --- a/docker/Dockerfile-coremltools-linux +++ b/docker/Dockerfile-coremltools-linux @@ -1,5 +1,5 @@ # An Ubuntu based image that is used for gitlab based ci infrastructure -FROM ubuntu:20.04 +FROM ubuntu:18.04 # Install dependencies, particularly libraries that python or CMake need RUN apt-get -y update \ diff --git a/modelpackage/src/ModelPackage.cpp b/modelpackage/src/ModelPackage.cpp index 0e59f0e78..47b586c2a 100644 --- a/modelpackage/src/ModelPackage.cpp +++ b/modelpackage/src/ModelPackage.cpp @@ -15,7 +15,17 @@ #include #include #include + +#if __has_include() #include +#elif __has_include() +#include +namespace std { + namespace filesystem = std::experimental::filesystem; +} +#else +#error "missing required header " +#endif #include #include