diff --git a/awslambdaric/bootstrap.py b/awslambdaric/bootstrap.py index cb8d5c3..efae4a3 100644 --- a/awslambdaric/bootstrap.py +++ b/awslambdaric/bootstrap.py @@ -37,7 +37,7 @@ def _get_handler(handler): try: - (modname, fname) = handler.rsplit(".", 1) + modname, fname = handler.rsplit(".", 1) except ValueError as e: raise FaultException( FaultException.MALFORMED_HANDLER_NAME, diff --git a/deps/aws-lambda-cpp-0.2.10.tar.gz b/deps/aws-lambda-cpp-0.2.10.tar.gz new file mode 100644 index 0000000..d8f726f Binary files /dev/null and b/deps/aws-lambda-cpp-0.2.10.tar.gz differ diff --git a/deps/aws-lambda-cpp-0.2.6.tar.gz b/deps/aws-lambda-cpp-0.2.6.tar.gz deleted file mode 100644 index 51d7f51..0000000 Binary files a/deps/aws-lambda-cpp-0.2.6.tar.gz and /dev/null differ diff --git a/deps/patches/aws-lambda-cpp-add-content-type.patch b/deps/patches/aws-lambda-cpp-add-content-type.patch index 2e045ff..46d3fda 100644 --- a/deps/patches/aws-lambda-cpp-add-content-type.patch +++ b/deps/patches/aws-lambda-cpp-add-content-type.patch @@ -46,7 +46,7 @@ index 08d7014..1cbd6bb 100644 @@ -275,6 +275,7 @@ runtime::next_outcome runtime::get_next() invocation_request req; req.payload = resp.get_body(); - req.request_id = resp.get_header(REQUEST_ID_HEADER); + req.request_id = std::move(out).get_result(); + req.content_type = resp.get_content_type(); if (resp.has_header(TRACE_ID_HEADER)) { diff --git a/deps/patches/aws-lambda-cpp-add-tenant-id.patch b/deps/patches/aws-lambda-cpp-add-tenant-id.patch index a7b7172..ea5cf31 100644 --- a/deps/patches/aws-lambda-cpp-add-tenant-id.patch +++ b/deps/patches/aws-lambda-cpp-add-tenant-id.patch @@ -26,14 +26,17 @@ index e53b2b8..9763282 100644 enum Endpoints { INIT, -@@ -289,6 +290,10 @@ runtime::next_outcome runtime::get_next() +@@ -289,6 +290,11 @@ runtime::next_outcome runtime::get_next() req.function_arn = resp.get_header(FUNCTION_ARN_HEADER); } -+ if (resp.has_header(TENANT_ID_HEADER)) { -+ req.tenant_id = resp.get_header(TENANT_ID_HEADER); ++ out = resp.get_header(TENANT_ID_HEADER); ++ if (out.is_success()) { ++ req.tenant_id = std::move(out).get_result(); + } + - if (resp.has_header(DEADLINE_MS_HEADER)) { - auto const& deadline_string = resp.get_header(DEADLINE_MS_HEADER); + out = resp.get_header(DEADLINE_MS_HEADER); + if (out.is_success()) { + auto const& deadline_string = std::move(out).get_result(); constexpr int base = 10; + diff --git a/deps/patches/aws-lambda-cpp-make-lto-optional.patch b/deps/patches/aws-lambda-cpp-make-lto-optional.patch deleted file mode 100644 index 54f78d2..0000000 --- a/deps/patches/aws-lambda-cpp-make-lto-optional.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index eb8327f..e6eeda5 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -4,10 +4,9 @@ project(aws-lambda-runtime - VERSION 0.2.6 - LANGUAGES CXX) - -+option(ENABLE_LTO "Enables link-time optimization, requires compiler support." ON) - option(ENABLE_TESTS "Enables building the test project, requires AWS C++ SDK." OFF) - --include(CheckIPOSupported) -- - add_library(${PROJECT_NAME} - "src/logging.cpp" - "src/runtime.cpp" -@@ -23,11 +22,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC - $ - $) - --check_ipo_supported(RESULT has_lto OUTPUT lto_check_output) --if(has_lto) -- set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) --else() -- message(WARNING "Link-time optimization (LTO) is not supported: ${lto_check_output}") -+if (ENABLE_LTO) -+ include(CheckIPOSupported) -+ check_ipo_supported(RESULT has_lto OUTPUT lto_check_output) -+ if(has_lto) -+ set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) -+ else() -+ message(WARNING "Link-time optimization (LTO) is not supported: ${lto_check_output}") -+ endif() - endif() - - find_package(CURL REQUIRED) diff --git a/deps/patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch b/deps/patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch deleted file mode 100644 index 8be3552..0000000 --- a/deps/patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 846392515b2b0215902aaf7368651af196835f10 Mon Sep 17 00:00:00 2001 -From: Bryan Moffatt -Date: Wed, 21 Oct 2020 12:42:37 -0700 -Subject: [PATCH] make the Runtime Interface Client's user agent overrideable (#106) - -* make the Runtime Interface Client's user agent overrideable - -* remove extra empty string - -* clang-format -i src/* ---- - include/aws/lambda-runtime/runtime.h | 2 ++ - src/runtime.cpp | 20 ++++++++------------ - 2 files changed, 10 insertions(+), 12 deletions(-) - -diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h -index 0dc292c..94e1e22 100644 ---- a/include/aws/lambda-runtime/runtime.h -+++ b/include/aws/lambda-runtime/runtime.h -@@ -137,6 +137,7 @@ public: - using next_outcome = aws::lambda_runtime::outcome; - using post_outcome = aws::lambda_runtime::outcome; - -+ runtime(std::string const& endpoint, std::string const& user_agent); - runtime(std::string const& endpoint); - ~runtime(); - -@@ -164,6 +165,7 @@ private: - invocation_response const& handler_response); - - private: -+ std::string const m_user_agent_header; - std::array const m_endpoints; - CURL* const m_curl_handle; - }; -diff --git a/src/runtime.cpp b/src/runtime.cpp -index e2ee7cd..f6131a4 100644 ---- a/src/runtime.cpp -+++ b/src/runtime.cpp -@@ -124,12 +124,6 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata) - return size * nmemb; - } - --static std::string const& get_user_agent_header() --{ -- static std::string user_agent = std::string("User-Agent: AWS_Lambda_Cpp/") + get_version(); -- return user_agent; --} -- - static size_t read_data(char* buffer, size_t size, size_t nitems, void* userdata) - { - auto const limit = size * nitems; -@@ -163,10 +157,12 @@ static int rt_curl_debug_callback(CURL* handle, curl_infotype type, char* data, - } - #endif - --runtime::runtime(std::string const& endpoint) -- : m_endpoints{{endpoint + "/2018-06-01/runtime/init/error", -- endpoint + "/2018-06-01/runtime/invocation/next", -- endpoint + "/2018-06-01/runtime/invocation/"}}, -+runtime::runtime(std::string const& endpoint) : runtime(endpoint, "AWS_Lambda_Cpp/" + std::string(get_version())) {} -+ -+runtime::runtime(std::string const& endpoint, std::string const& user_agent) -+ : m_user_agent_header("User-Agent: " + user_agent), m_endpoints{{endpoint + "/2018-06-01/runtime/init/error", -+ endpoint + "/2018-06-01/runtime/invocation/next", -+ endpoint + "/2018-06-01/runtime/invocation/"}}, - m_curl_handle(curl_easy_init()) - { - if (!m_curl_handle) { -@@ -234,7 +230,7 @@ runtime::next_outcome runtime::get_next() - curl_easy_setopt(m_curl_handle, CURLOPT_HEADERDATA, &resp); - - curl_slist* headers = nullptr; -- headers = curl_slist_append(headers, get_user_agent_header().c_str()); -+ headers = curl_slist_append(headers, m_user_agent_header.c_str()); - curl_easy_setopt(m_curl_handle, CURLOPT_HTTPHEADER, headers); - - logging::log_debug(LOG_TAG, "Making request to %s", m_endpoints[Endpoints::NEXT].c_str()); -@@ -343,7 +343,7 @@ runtime::post_outcome runtime::do_post( - headers = curl_slist_append(headers, ("lambda-runtime-function-xray-error-cause: " + xray_response).c_str()); - headers = curl_slist_append(headers, "Expect:"); - headers = curl_slist_append(headers, "transfer-encoding:"); -- headers = curl_slist_append(headers, get_user_agent_header().c_str()); -+ headers = curl_slist_append(headers, m_user_agent_header.c_str()); - - logging::log_debug( - LOG_TAG, "calculating content length... %s", ("content-length: " + std::to_string(payload.length())).c_str()); --- -2.25.2 - diff --git a/deps/patches/aws-lambda-cpp-posting-init-errors.patch b/deps/patches/aws-lambda-cpp-posting-init-errors.patch deleted file mode 100644 index 7635443..0000000 --- a/deps/patches/aws-lambda-cpp-posting-init-errors.patch +++ /dev/null @@ -1,206 +0,0 @@ -diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h -index be77d93..9597272 100644 ---- a/include/aws/lambda-runtime/runtime.h -+++ b/include/aws/lambda-runtime/runtime.h -@@ -67,28 +67,58 @@ struct invocation_request { - inline std::chrono::milliseconds get_time_remaining() const; - }; - --class invocation_response { --private: -+class runtime_response { -+protected: - /** -- * The output of the function which is sent to the lambda caller. -+ * The response payload from the runtime. - */ - std::string m_payload; - - /** - * The MIME type of the payload. -- * This is always set to 'application/json' in unsuccessful invocations. - */ - std::string m_content_type; - - /** -- * Flag to distinguish if the contents are for successful or unsuccessful invocations. -+ * The serialized XRay response header. - */ -- bool m_success; -+ std::string m_xray_response; - - /** -- * The serialized XRay response header. -+ * Instantiate an empty response. - */ -- std::string m_xray_response; -+ runtime_response() = default; -+public: -+ /* Create a runtime response with the given payload, content type and xray response. This can be used for constructing an -+ * initialization error response. For invocation success and failure response, see invocation_response. -+ */ -+ runtime_response(std::string const& payload, std::string const& content_type, std::string const& xray_response) -+ : m_payload(payload), m_content_type(content_type), m_xray_response(xray_response) -+ { -+ } -+ -+ /** -+ * Get the payload string. The string is assumed to be UTF-8 encoded. -+ */ -+ std::string const& get_payload() const { return m_payload; } -+ -+ /** -+ * Get the MIME type of the payload. -+ */ -+ std::string const& get_content_type() const { return m_content_type; } -+ -+ /** -+ * Get the XRay response string. The string is assumed to be UTF-8 encoded. -+ */ -+ std::string const& get_xray_response() const { return m_xray_response; } -+}; -+ -+class invocation_response: public runtime_response { -+private: -+ /** -+ * Flag to distinguish if the contents are for successful or unsuccessful invocations. -+ */ -+ bool m_success; - - /** - * Instantiate an empty response. Used by the static functions 'success' and 'failure' to create a populated -@@ -102,12 +132,10 @@ public: - // To support clients that need to control the entire error response body (e.g. adding a stack trace), this - // constructor should be used instead. - // Note: adding an overload to invocation_response::failure is not feasible since the parameter types are the same. -- invocation_response(std::string const& payload, std::string const& content_type, bool success, std::string const& xray_response): -- m_payload(payload), -- m_content_type(content_type), -- m_success(success), -- m_xray_response(xray_response) -- {} -+ invocation_response(std::string const& payload, std::string const& content_type, bool success, std::string const& xray_response) -+ : runtime_response(payload, content_type, xray_response), m_success(success) -+ { -+ } - - /** - * Create a successful invocation response with the given payload and content-type. -@@ -120,25 +148,10 @@ public: - */ - static invocation_response failure(std::string const& error_message, std::string const& error_type, std::string const& xray_response); - -- /** -- * Get the MIME type of the payload. -- */ -- std::string const& get_content_type() const { return m_content_type; } -- -- /** -- * Get the payload string. The string is assumed to be UTF-8 encoded. -- */ -- std::string const& get_payload() const { return m_payload; } -- - /** - * Returns true if the payload and content-type are set. Returns false if the error message and error types are set. - */ - bool is_success() const { return m_success; } -- -- /** -- * Get the XRay response string. The string isassumed to be UTF-8 encoded. -- */ -- std::string const& get_xray_response() const { return m_xray_response; } - }; - - struct no_result { -@@ -167,13 +180,19 @@ public: - */ - post_outcome post_failure(std::string const& request_id, invocation_response const& handler_response); - -+ /** -+ * Tells lambda that the runtime has failed during initialization. -+ */ -+ post_outcome post_init_error(runtime_response const& init_error_response); -+ - private: - void set_curl_next_options(); - void set_curl_post_result_options(); - post_outcome do_post( - std::string const& url, -- std::string const& request_id, -- invocation_response const& handler_response); -+ std::string const& content_type, -+ std::string const& payload, -+ std::string const& xray_response); - - private: - std::array const m_endpoints; -diff --git a/src/runtime.cpp b/src/runtime.cpp -index d895c4b..659666e 100644 ---- a/src/runtime.cpp -+++ b/src/runtime.cpp -@@ -311,37 +311,44 @@ runtime::next_outcome runtime::get_next() - runtime::post_outcome runtime::post_success(std::string const& request_id, invocation_response const& handler_response) - { - std::string const url = m_endpoints[Endpoints::RESULT] + request_id + "/response"; -- return do_post(url, request_id, handler_response); -+ return do_post(url, handler_response.get_content_type(), handler_response.get_payload(), handler_response.get_xray_response()); - } - - runtime::post_outcome runtime::post_failure(std::string const& request_id, invocation_response const& handler_response) - { - std::string const url = m_endpoints[Endpoints::RESULT] + request_id + "/error"; -- return do_post(url, request_id, handler_response); -+ return do_post(url, handler_response.get_content_type(), handler_response.get_payload(), handler_response.get_xray_response()); -+} -+ -+runtime::post_outcome runtime::post_init_error(runtime_response const& init_error_response) -+{ -+ std::string const url = m_endpoints[Endpoints::INIT]; -+ return do_post(url, init_error_response.get_content_type(), init_error_response.get_payload(), init_error_response.get_xray_response()); - } - - runtime::post_outcome runtime::do_post( - std::string const& url, -- std::string const& request_id, -- invocation_response const& handler_response) -+ std::string const& content_type, -+ std::string const& payload, -+ std::string const& xray_response) - { - set_curl_post_result_options(); - curl_easy_setopt(m_curl_handle, CURLOPT_URL, url.c_str()); - logging::log_info(LOG_TAG, "Making request to %s", url.c_str()); - - curl_slist* headers = nullptr; -- if (handler_response.get_content_type().empty()) { -+ if (content_type.empty()) { - headers = curl_slist_append(headers, "content-type: text/html"); - } - else { -- headers = curl_slist_append(headers, ("content-type: " + handler_response.get_content_type()).c_str()); -+ headers = curl_slist_append(headers, ("content-type: " + content_type).c_str()); - } - -- headers = curl_slist_append(headers, ("lambda-runtime-function-xray-error-cause: " + handler_response.get_xray_response()).c_str()); -+ headers = curl_slist_append(headers, ("lambda-runtime-function-xray-error-cause: " + xray_response).c_str()); - headers = curl_slist_append(headers, "Expect:"); - headers = curl_slist_append(headers, "transfer-encoding:"); - headers = curl_slist_append(headers, get_user_agent_header().c_str()); -- auto const& payload = handler_response.get_payload(); -+ - logging::log_debug( - LOG_TAG, "calculating content length... %s", ("content-length: " + std::to_string(payload.length())).c_str()); - headers = curl_slist_append(headers, ("content-length: " + std::to_string(payload.length())).c_str()); -@@ -358,10 +365,10 @@ runtime::post_outcome runtime::do_post( - if (curl_code != CURLE_OK) { - logging::log_debug( - LOG_TAG, -- "CURL returned error code %d - %s, for invocation %s", -+ "CURL returned error code %d - %s, when calling %s", - curl_code, - curl_easy_strerror(curl_code), -- request_id.c_str()); -+ url.c_str()); - return aws::http::response_code::REQUEST_NOT_MADE; - } - diff --git a/deps/versions b/deps/versions index 63b0efc..9eb9951 100644 --- a/deps/versions +++ b/deps/versions @@ -1,4 +1,4 @@ -AWS_LAMBDA_CPP_RELEASE=0.2.6 +AWS_LAMBDA_CPP_RELEASE=0.2.10 CURL_MAJOR_VERSION=7 CURL_MINOR_VERSION=83 CURL_PATCH_VERSION=1 diff --git a/scripts/preinstall.sh b/scripts/preinstall.sh index b377228..aa1bd55 100755 --- a/scripts/preinstall.sh +++ b/scripts/preinstall.sh @@ -4,54 +4,55 @@ set -e ARTIFACTS_DIR=$(pwd)/deps/artifacts -if [ "$(uname)" = "Darwin" ]; then - echo "aws-lambda-cpp does not build on OS X. Skipping the preinstall step." + +if [ -x "$(command -v cmake3)" ]; then + CMAKE=cmake3 +elif [ -x "$(command -v cmake)" ]; then + CMAKE=cmake else - if [ -x "$(command -v cmake3)" ]; then - CMAKE=cmake3 - elif [ -x "$(command -v cmake)" ]; then - CMAKE=cmake - else - echo 'Error: cmake is not installed.' >&2 - exit 1 - fi - - cd deps - . ./versions - - CURL_VERSION="${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION}" - - rm -rf ./curl-$CURL_VERSION - rm -rf ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE - - # unpack dependencies - tar xzf ./curl-$CURL_VERSION.tar.gz --no-same-owner && \ - tar xzf ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE.tar.gz --no-same-owner - - ( - # Build Curl - cd curl-$CURL_VERSION && \ - ./buildconf && \ - ./configure \ - --prefix "$ARTIFACTS_DIR" \ - --disable-shared \ - --without-ssl \ - --with-pic \ - --without-zlib && \ - make && \ - make install - ) - - ( - # Build aws-lambda-cpp - mkdir -p ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE/build && \ - cd ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE/build - - $CMAKE .. \ - -DCMAKE_CXX_FLAGS="-fPIC" \ - -DCMAKE_INSTALL_PREFIX="$ARTIFACTS_DIR" \ - -DENABLE_LTO=$ENABLE_LTO \ - -DCMAKE_MODULE_PATH="$ARTIFACTS_DIR"/lib/pkgconfig && \ - make && make install - ) -fi \ No newline at end of file + echo 'Error: cmake is not installed.' >&2 + exit 1 +fi + +skip () { + [ "$(uname)" = "Darwin" ] +} + +cd deps +. ./versions + +CURL_VERSION="${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION}" + +skip || rm -rf ./curl-$CURL_VERSION +rm -rf ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE + +# unpack dependencies +skip || tar xzf ./curl-$CURL_VERSION.tar.gz --no-same-owner && \ +tar xzf ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE.tar.gz --no-same-owner + +skip || ( + # Build Curl + cd curl-$CURL_VERSION && \ + ./buildconf && \ + ./configure \ + --prefix "$ARTIFACTS_DIR" \ + --disable-shared \ + --without-ssl \ + --with-pic \ + --without-zlib && \ + make && \ + make install +) + +( + # Build aws-lambda-cpp + mkdir -p ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE/build && \ + cd ./aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE/build + + $CMAKE .. \ + -DCMAKE_CXX_FLAGS="-fPIC" \ + -DCMAKE_INSTALL_PREFIX="$ARTIFACTS_DIR" \ + -DENABLE_LTO=$ENABLE_LTO \ + -DCMAKE_MODULE_PATH="$ARTIFACTS_DIR"/lib/pkgconfig && \ + make && make install +) diff --git a/scripts/update_deps.sh b/scripts/update_deps.sh index 4799a6f..d1ef4af 100755 --- a/scripts/update_deps.sh +++ b/scripts/update_deps.sh @@ -1,13 +1,14 @@ #!/bin/bash # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. -set -x +set -euox pipefail cd deps source versions # Clean up old files -rm -f aws-lambda-cpp-*.tar.gz && rm -f curl-*.tar.gz - +rm -f aws-lambda-cpp-*.tar.gz +rm -f curl-*.tar.gz +rm -rf aws-lambda-cpp-* LIBCURL="curl-${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION}" @@ -18,22 +19,19 @@ wget -c "https://github.com/curl/curl/releases/download/curl-${CURL_MAJOR_VERSIO patch -p1 < ../patches/libcurl-configure-template.patch ) -tar -czf $LIBCURL.tar.gz $LIBCURL --no-same-owner && rm -rf $LIBCURL +tar --no-same-owner -czf $LIBCURL.tar.gz $LIBCURL && rm -rf $LIBCURL # Grab aws-lambda-cpp wget -c https://github.com/awslabs/aws-lambda-cpp/archive/v$AWS_LAMBDA_CPP_RELEASE.tar.gz -O - | tar -xz ## Apply patches to aws-lambda-cpp ( - cd aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE && \ - patch -p1 < ../patches/aws-lambda-cpp-add-xray-response.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-posting-init-errors.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-make-lto-optional.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-add-content-type.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-add-tenant-id.patch + cd aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE + patch -p1 < ../patches/aws-lambda-cpp-add-xray-response.patch + patch -p1 < ../patches/aws-lambda-cpp-add-content-type.patch + patch -p1 < ../patches/aws-lambda-cpp-add-tenant-id.patch ) ## Pack again and remove the folder -tar -czf aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE.tar.gz aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE --no-same-owner && \ - rm -rf aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE +tar --no-same-owner -czf aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE.tar.gz aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE +rm -rf aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE diff --git a/setup.py b/setup.py index 2bf28ef..45e0b30 100644 --- a/setup.py +++ b/setup.py @@ -12,14 +12,17 @@ def get_curl_extra_linker_flags(): # We do not want to build the dependencies during packaging - if platform.system() != "Linux" or os.getenv("BUILD") == "true": + if platform.system() not in {"Linux", "Darwin"} or os.getenv("BUILD") == "true": return [] # Build the dependencies check_call(["./scripts/preinstall.sh"]) # call curl-config to get the required linker flags - cmd = ["./deps/artifacts/bin/curl-config", "--static-libs"] + if platform.system() in {"Darwin"}: + cmd = ["curl-config", "--libs"] + else: + cmd = ["./deps/artifacts/bin/curl-config", "--static-libs"] curl_config = check_output(cmd).decode("utf-8").replace("\n", "") # It is expected that the result of the curl-config call is similar to @@ -31,7 +34,7 @@ def get_curl_extra_linker_flags(): def get_runtime_client_extension(): - if platform.system() != "Linux" and os.getenv("BUILD") != "true": + if platform.system() not in {"Linux", "Darwin"} and os.getenv("BUILD") != "true": print( "The native runtime_client only builds on Linux. Skipping its compilation." )