1#!/bin/bash 2# Copyright 2020 Google LLC 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15################################################################################ 16 17 18set -euo pipefail 19 20# The following assoicative array contains: 21# ["<Python version>"]="<python tag>-<abi tag>" 22# where: 23# <Python version> = language version, e.g "3.7" 24# <python tag>, <abi tag> = as defined at 25# https://packaging.python.org/en/latest/specifications/, e.g. "cp37-37m" 26declare -A PYTHON_VERSIONS 27PYTHON_VERSIONS["3.7"]="cp37-cp37m" 28PYTHON_VERSIONS["3.8"]="cp38-cp38" 29PYTHON_VERSIONS["3.9"]="cp39-cp39" 30PYTHON_VERSIONS["3.10"]="cp310-cp310" 31readonly -A PYTHON_VERSIONS 32 33readonly ARCH="$(uname -m)" 34 35# This is a compressed tag set as specified at 36# https://peps.python.org/pep-0425/#compressed-tag-sets 37# 38# Keep in sync with the output of the auditwheel tool. 39PLATFORM_TAG_SET="manylinux_2_17_x86_64.manylinux2014_x86_64" 40if [[ "${ARCH}" == "aarch64" || "${ARCH}" == "arm64" ]]; then 41 PLATFORM_TAG_SET="manylinux_2_17_aarch64.manylinux2014_aarch64" 42fi 43readonly PLATFORM_TAG_SET 44 45export TINK_PYTHON_ROOT_PATH="${PWD}" 46 47# Required to fix https://github.com/pypa/manylinux/issues/357. 48export LD_LIBRARY_PATH="/usr/local/lib" 49 50# This link is required on CentOS, as curl used in the AWS SDK looks for the 51# certificates in this location. Removing this line will cause the AWS KMS tests 52# to fail. 53ln -s /etc/ssl/certs/ca-bundle.trust.crt /etc/ssl/certs/ca-certificates.crt 54 55TEST_IGNORE_PATHS=( -not -path "*cc/pybind*") 56if [[ "${ARCH}" == "aarch64" || "${ARCH}" == "arm64" ]]; then 57 # gRPC doesn't seem compatible with libstdc++ present in 58 # manylinux2014_aarch64 (see https://github.com/grpc/grpc/issues/33734). 59 # TODO(b/291055539): Re-enable these tests when/after this is solved. 60 TEST_IGNORE_PATHS+=( -not -path "*integration/gcpkms*") 61fi 62readonly TEST_IGNORE_PATHS 63 64for v in "${!PYTHON_VERSIONS[@]}"; do 65 ( 66 # Executing in a subshell to make the PATH modification temporary. 67 export PATH="${PATH}:/opt/python/${PYTHON_VERSIONS[$v]}/bin" 68 python3 -m pip install --require-hashes -r requirements.txt 69 python3 -m pip install --no-deps --no-index \ 70 release/*-"${PYTHON_VERSIONS[$v]}"-"${PLATFORM_TAG_SET}".whl 71 find tink/ "${TEST_IGNORE_PATHS[@]}" -type f -name "*_test.py" -print0 \ 72 | xargs -0 -n1 python3 73 ) 74done 75