From 89c1f4bafb51dbbed705b6960810d90825318b13 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Fri, 16 Sep 2022 18:09:32 +0100 Subject: MLIA-646 Add environment to setup pre-commit hooks - Add new environment 'lint_setup' to set up the pre-commit hooks used by the environment 'lint' without running the actual tests. - Add docker file for linting and testing to the project root. - Add helper script 'install_python_versions.sh' for docker creation. Change-Id: I5f264df72a72d7a118ab798eddcf0febd4e1125b --- docker/install_python_versions.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 docker/install_python_versions.sh (limited to 'docker') diff --git a/docker/install_python_versions.sh b/docker/install_python_versions.sh new file mode 100755 index 0000000..c3cd976 --- /dev/null +++ b/docker/install_python_versions.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 + +set -e +set -u +set -o pipefail + +# Set one or multiple python versions through pyenv to be available globally +function set_python_global_versions() { + py_versions=$1 + parsed_versions="" + + # Find correct parsed subversion for each provided version + for i in $(echo "$py_versions" | tr ";" "\n") + do + parsed_versions+=$(pyenv versions | grep "$i") + parsed_versions+=" " + done + # Set global versions + echo "$parsed_versions" | xargs pyenv global +} + +# Install all python versions provided as parameter using pyenv +# if the --set-all-global flag is set, make all installed versions +# available globally. +py_versions=$1 +parameters=$2 +for i in $(echo "$py_versions" | tr ";" "\n") +do + pyenv install "$i":latest +done + +if [ "$parameters" == "--set-all-global" ]; then + set_python_global_versions "$1" +fi -- cgit v1.2.1