Skip to content

Commit

Permalink
fix: compatibility with Ubuntu 18.04 (apple#1232)
Browse files Browse the repository at this point in the history
Fixes compatibility with Ubuntu 18.04 by:

* Downgrading our build image from 20.04 to 18.04
* Fall back to using <experimental/filesystem> for compatibility with the libstdc++ on 18.04, with corresponding linking to stdc++fs
  • Loading branch information
Zach Nation authored Jul 1, 2021
1 parent 744f130 commit 58adf98
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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}
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-coremltools-linux
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
10 changes: 10 additions & 0 deletions modelpackage/src/ModelPackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@
#include <sstream>
#include <istream>
#include <string>

#if __has_include(<filesystem>)
#include <filesystem>
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace std {
namespace filesystem = std::experimental::filesystem;
}
#else
#error "missing required header <filesystem>"
#endif
#include <uuid/uuid.h>
#include <vector>

Expand Down

0 comments on commit 58adf98

Please sign in to comment.