From 7e780324141ed9e6eacc80f831a567b45c00806b Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 28 Oct 2023 01:30:31 +0200 Subject: [PATCH] add PyPY to hostedtoolcache --- .cspell.json | 1 + docker-bake.hcl | 5 +++++ linux/ubuntu/Dockerfile | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/.cspell.json b/.cspell.json index b067f37..d4b3625 100644 --- a/.cspell.json +++ b/.cspell.json @@ -114,6 +114,7 @@ "pkrvars", "pulumi", "pwsh", + "pypy", "quickview", "realpath", "rubygems", diff --git a/docker-bake.hcl b/docker-bake.hcl index dfe697b..bde1218 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -82,6 +82,10 @@ variable "POWERSHELL_MODULES" { default = "[\"MarkdownPS\",\"Microsoft.Graph\",\"Pester\",\"PSScriptAnalyzer\"]" } +variable "PYPY_VERSIONS" { + default = "[\"3.10\",\"3.9\",\"3.8\",\"3.7\"]" +} + group "default" { targets = [ "ubuntu" @@ -133,6 +137,7 @@ target "ubuntu" { POWERSHELL_MODULES = POWERSHELL_MODULES POWERSHELL_VERSION = release.POWERSHELL_VERSION PULUMI_VERSION = PULUMI_VERSION + PYPY_VERSIONS = PYPY_VERSIONS RUSTUP_HOME = "/usr/local/rustup" TOOL_PATH_PWSH = "/usr/share/powershell" } diff --git a/linux/ubuntu/Dockerfile b/linux/ubuntu/Dockerfile index c76d557..d7d69fa 100644 --- a/linux/ubuntu/Dockerfile +++ b/linux/ubuntu/Dockerfile @@ -209,6 +209,35 @@ RUN KUBECTL_VERSION=$(curl -fsSL "https://dl.k8s.io/release/stable.txt") \ && curl -sSLO "https://storage.googleapis.com/minikube/releases/latest/minikube-linux-${TARGETARCH}" \ && install "minikube-linux-${TARGETARCH}" "${PATH_LOCAL_BINS}/minikube" +FROM base as pypy +SHELL [ "/bin/bash", "--login", "-e", "-o", "pipefail", "-c" ] +ARG PYPY_VERSIONS +RUN export PYPY_VERSIONS_JSON=/tmp/pypy_versions.json \ + && curl -fsSL https://downloads.python.org/pypy/versions.json -o "${PYPY_VERSIONS_JSON}" \ + && arch="$(uname -m)" && if [[ "${arch}" = "x86_64" ]]; then arch="x64"; fi \ + && export arch \ + && export PYPY_TMP_ARCHIVE=/tmp/pypy.tar.bz2 \ + && versions=() \ + && while IFS='' read -r version; do versions+=("$version"); done < <(printf "%s\n" "${PYPY_VERSIONS}" | jq -r '.[]') \ + && for version in "${versions[@]}"; do latest_python_version=$(jq --arg version "$version" -r '.[] | select((.python_version | startswith($version)) and (.stable==true)) | .python_version' "${PYPY_VERSIONS_JSON}" | sort -V | tail -n1) \ + && echo "loading PyPY ${latest_python_version} for arch ${arch}" \ + && curl -fsSL "$(jq \ + --arg latest_python_version "${latest_python_version}" \ + --arg arch "${arch}" \ + -r 'map(select((.python_version==$latest_python_version) and .stable==true) | .files[] | select((.arch==$arch) and (.platform=="linux")) | .download_url) | .[]' "${PYPY_VERSIONS_JSON}")" \ + -o "${PYPY_TMP_ARCHIVE}" \ + && PYPY_TOOLCACHE_DIR="${AGENT_TOOLSDIRECTORY}/PyPY" \ + && PYPY_TOOLCACHE_VERSION_DIR="${PYPY_TOOLCACHE_DIR}/${latest_python_version}" \ + && PYPY_TOOLCACHE_VERSION_ARCH_DIR="${PYPY_TOOLCACHE_VERSION_DIR}/${arch}" \ + && mkdir -p "$PYPY_TOOLCACHE_VERSION_ARCH_DIR" \ + && tar -xjf "${PYPY_TMP_ARCHIVE}" \ + --strip-components=1 \ + -C "$PYPY_TOOLCACHE_VERSION_ARCH_DIR" \ + && printf "%s\n" "$("${PYPY_TOOLCACHE_VERSION_ARCH_DIR}/bin/python" -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))")" >"${PYPY_TOOLCACHE_VERSION_ARCH_DIR}/PYPY_VERSION" \ + && touch "${PYPY_TOOLCACHE_VERSION_ARCH_DIR}.complete" \ + && rm "${PYPY_TMP_ARCHIVE}"; done \ + && rm "${PYPY_VERSIONS_JSON}" + FROM base as terraform ARG TARGETARCH ARG PATH_LOCAL_BINS @@ -436,6 +465,9 @@ COPY --link --from=k8s-tools \ "${PATH_LOCAL_BINS}/minikube" \ "${PATH_LOCAL_BINS}"/ +# add PyPy +COPY --link --from=pypy "${AGENT_TOOLSDIRECTORY}/PyPY" "${AGENT_TOOLSDIRECTORY}/PyPY" + # add terraform COPY --link --from=terraform "${PATH_LOCAL_BINS}/terraform" "${PATH_LOCAL_BINS}/terraform"