From 8f1a1f858fa61785355b264e7d22e6be1891b311 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 16 Oct 2024 16:36:56 -0500 Subject: [PATCH 01/16] Add install python command --- .circleci/test-deploy.yml | 35 +++++++++++++++++++++++- src/commands/install.yml | 14 ++++++++++ src/scripts/cache-save.sh | 4 --- src/scripts/install-python.sh | 50 +++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 src/commands/install.yml create mode 100644 src/scripts/install-python.sh diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 1d44334..85e1edf 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -14,8 +14,30 @@ executors: macos: macos: xcode: 16.1 - + machine: + machine: + image: ubuntu-2004:current + machine-arm: + resource_class: arm.medium + machine: + image: ubuntu-2004:current + docker-latest: + docker: + - image: cimg/base:stable jobs: + install-python: + parameters: + executor: + type: executor + default: machine + version: + type: string + default: 3.11.10 + executor: <> + steps: + - python/install: + version: <> + pip-install-test: parameters: executor: @@ -143,6 +165,16 @@ workflows: test-deploy: jobs: # Make sure to include "filters: *filters" in every test job you want to run as part of your deployment. + - pip-install-test-no-packages: + filters: *filters + - install-python: + filters: *filters + name: install-python-<>-<> + matrix: + alias: install-python + parameters: + executor: ["machine", "machine-arm","macos", "docker-latest"] + version: ["3.11", "3.8", "3.12", "3.11.5", "3.9.4"] - pip-install-test: name: "pip-install-macos" filters: *filters @@ -294,6 +326,7 @@ workflows: - dist-test-wheel - dist-test-build - dist-test-build-opts + - install-python context: orb-publisher filters: branches: diff --git a/src/commands/install.yml b/src/commands/install.yml new file mode 100644 index 0000000..3de0e6e --- /dev/null +++ b/src/commands/install.yml @@ -0,0 +1,14 @@ +description: "Install the specified version of python" + +parameters: + version: + type: string + default: 3.11.10 + description: Python version to install + +steps: + - run: + name: Install Python + command: <> + environment: + PARAM_VERSION: << parameters.version >> \ No newline at end of file diff --git a/src/scripts/cache-save.sh b/src/scripts/cache-save.sh index 951b9db..99cb22a 100755 --- a/src/scripts/cache-save.sh +++ b/src/scripts/cache-save.sh @@ -62,10 +62,6 @@ fi LOCKFILE_PATH="${CACHE_DIR}/lockfile" -if [ -e "${LOCKFILE_PATH}" ]; then - rm -f "${LOCKFILE_PATH}" -fi - if [ -e "${LOCK_FILE}" ]; then FULL_LOCK_FILE=$(readlink -f "${LOCK_FILE}") diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh new file mode 100644 index 0000000..7036227 --- /dev/null +++ b/src/scripts/install-python.sh @@ -0,0 +1,50 @@ +#!/bin/bash +PARAM_VERSION="$(echo "${PARAM_VERSION}" | circleci env subst)" +IFS='.' +read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" + +Install_Python() { + wget "https://www.python.org/ftp/python/$PARAM_VERSION/Python-$PARAM_VERSION.tgz" + tar -xf Python-$PARAM_VERSION.tgz + rm -f Python-$PARAM_VERSION.tgz + cd Python-$PARAM_VERSION + ./configure --enable-optimizations + make + $SUDO make altinstall + + ln -s "/usr/local/bin/python$MAJOR.$MINOR" "/usr/bin/python$MAJOR.$MINOR" + "python$MAJOR.$MINOR" -m ensurepip --upgrade + "python$MAJOR.$MINOR" -m pip install --upgrade pip + ln -s "/usr/local/bin/pip$MAJOR.$MINOR" "/usr/bin/pip$MAJOR.$MINOR" + + shopt -s expand_aliases + alias python="python$MAJOR.$MINOR" + alias pip="pip$MAJOR.$MINOR" + echo "export BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" +} + +if [ "$SYS_ENV_PLATFORM" = "linux_alpine" ]; then + if [ "$ID" = 0 ]; then export SUDO=""; else export SUDO="sudo"; fi +else + if [ "$EUID" = 0 ]; then export SUDO=""; else export SUDO="sudo"; fi +fi + +if [ -z "$MAJOR" ] || [ -z "$MINOR" ]; then + echo "The version provide: $PARAM_VERSION is not valid" + exit 1 +fi + +# The release is only found with the format x.x.x, if the format is x.x detect the latest version for x.x +if [ -z "$PATCH" ]; then + PATCHES=$(curl https://www.python.org/ftp/python/ | grep -Po "(?<=href=\")$PARAM_VERSION\.[0-9]+(?=/\")") + LATEST_PATCH=$(echo "$PATCHES" | sort -V | tail -n 1) + PARAM_VERSION="$LATEST_PATCH" + read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" +fi + +if ! command -v "python$MAJOR.$MINOR" >/dev/null 2>&1; then + Install_Python +else + echo "Python$MAJOR.$MINOR is already installed" + exit 0 +fi From 6c0d1c31d361f9cffe42b68682e628b63d7e29c7 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 08:56:06 -0500 Subject: [PATCH 02/16] Solve shellchecks --- src/scripts/install-python.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 7036227..0c10fa4 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -7,7 +7,7 @@ Install_Python() { wget "https://www.python.org/ftp/python/$PARAM_VERSION/Python-$PARAM_VERSION.tgz" tar -xf Python-$PARAM_VERSION.tgz rm -f Python-$PARAM_VERSION.tgz - cd Python-$PARAM_VERSION + cd Python-$PARAM_VERSION || exit 1 ./configure --enable-optimizations make $SUDO make altinstall @@ -18,7 +18,9 @@ Install_Python() { ln -s "/usr/local/bin/pip$MAJOR.$MINOR" "/usr/bin/pip$MAJOR.$MINOR" shopt -s expand_aliases + # shellcheck disable=SC2139 alias python="python$MAJOR.$MINOR" + # shellcheck disable=SC2139 alias pip="pip$MAJOR.$MINOR" echo "export BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" } From ffa97ff4d4f3748dd77f666d284e69d6dbe5aa4e Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 09:02:31 -0500 Subject: [PATCH 03/16] Fix linting --- src/commands/install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/install.yml b/src/commands/install.yml index 3de0e6e..8f2f228 100644 --- a/src/commands/install.yml +++ b/src/commands/install.yml @@ -11,4 +11,4 @@ steps: name: Install Python command: <> environment: - PARAM_VERSION: << parameters.version >> \ No newline at end of file + PARAM_VERSION: << parameters.version >> From 7ab4603effe53fe916eee820a4e5adcb78b1c09e Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 09:10:05 -0500 Subject: [PATCH 04/16] Fix: add missing quotes on string --- .circleci/test-deploy.yml | 11 ----------- src/scripts/install-python.sh | 6 +++--- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index c64e0c4..a7c41f3 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -68,15 +68,6 @@ jobs: working_directory: ~/project/sample_pip command: | pytest - pip-install-test-no-packages: - executor: python/default - steps: - - checkout - - run: - name: "Test" - working_directory: ~/project/sample_pip - command: | - pytest pip-install-test-args: executor: python/default steps: @@ -165,8 +156,6 @@ workflows: test-deploy: jobs: # Make sure to include "filters: *filters" in every test job you want to run as part of your deployment. - - pip-install-test-no-packages: - filters: *filters - install-python: filters: *filters name: install-python-<>-<> diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 0c10fa4..df78436 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -5,9 +5,9 @@ read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" Install_Python() { wget "https://www.python.org/ftp/python/$PARAM_VERSION/Python-$PARAM_VERSION.tgz" - tar -xf Python-$PARAM_VERSION.tgz - rm -f Python-$PARAM_VERSION.tgz - cd Python-$PARAM_VERSION || exit 1 + tar -xf "Python-$PARAM_VERSION.tgz" + rm -f "Python-$PARAM_VERSION.tgz" + cd "Python-$PARAM_VERSION" || exit 1 ./configure --enable-optimizations make $SUDO make altinstall From 2a457705b839085348fa37edf9c9ad94ff8afa21 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 11:30:40 -0500 Subject: [PATCH 05/16] Use pyenv --- .circleci/test-deploy.yml | 9 +++++++- src/scripts/install-python.sh | 41 ++++++++++++----------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index a7c41f3..a15482b 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -11,6 +11,9 @@ parameters: default: v4 executors: + python: + docker: + - image: cimg/python:3.8 macos: macos: xcode: 16.1 @@ -162,8 +165,12 @@ workflows: matrix: alias: install-python parameters: - executor: ["machine", "machine-arm","macos", "docker-latest"] + executor: ["machine", "machine-arm","macos", "docker-latest", "python"] version: ["3.11", "3.8", "3.12", "3.11.5", "3.9.4"] + post-steps: + - run: + name: Verify python version is right + command: python --version | grep "Python <>" - pip-install-test: name: "pip-install-macos" filters: *filters diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index df78436..4663272 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -3,26 +3,21 @@ PARAM_VERSION="$(echo "${PARAM_VERSION}" | circleci env subst)" IFS='.' read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" -Install_Python() { - wget "https://www.python.org/ftp/python/$PARAM_VERSION/Python-$PARAM_VERSION.tgz" - tar -xf "Python-$PARAM_VERSION.tgz" - rm -f "Python-$PARAM_VERSION.tgz" - cd "Python-$PARAM_VERSION" || exit 1 - ./configure --enable-optimizations - make - $SUDO make altinstall - - ln -s "/usr/local/bin/python$MAJOR.$MINOR" "/usr/bin/python$MAJOR.$MINOR" - "python$MAJOR.$MINOR" -m ensurepip --upgrade - "python$MAJOR.$MINOR" -m pip install --upgrade pip - ln -s "/usr/local/bin/pip$MAJOR.$MINOR" "/usr/bin/pip$MAJOR.$MINOR" +Install_Pyenv() { + curl https://pyenv.run | bash + echo "export PATH=$HOME/.pyenv/bin:$PATH" >> "$BASH_ENV" + . "$BASH_ENV" +} - shopt -s expand_aliases - # shellcheck disable=SC2139 - alias python="python$MAJOR.$MINOR" - # shellcheck disable=SC2139 - alias pip="pip$MAJOR.$MINOR" - echo "export BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" +Install_Python() { + if ! command -v "pyenv" >/dev/null 2>&1; then + Install_Pyenv + else + echo "Pyenv is already installed" + fi + pyenv install "$PARAM_VERSION" + pyenv global "$PARAM_VERSION" + echo "BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" } if [ "$SYS_ENV_PLATFORM" = "linux_alpine" ]; then @@ -36,14 +31,6 @@ if [ -z "$MAJOR" ] || [ -z "$MINOR" ]; then exit 1 fi -# The release is only found with the format x.x.x, if the format is x.x detect the latest version for x.x -if [ -z "$PATCH" ]; then - PATCHES=$(curl https://www.python.org/ftp/python/ | grep -Po "(?<=href=\")$PARAM_VERSION\.[0-9]+(?=/\")") - LATEST_PATCH=$(echo "$PATCHES" | sort -V | tail -n 1) - PARAM_VERSION="$LATEST_PATCH" - read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" -fi - if ! command -v "python$MAJOR.$MINOR" >/dev/null 2>&1; then Install_Python else From 52534e2d39147919112cab411918592a5d384aeb Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 11:38:55 -0500 Subject: [PATCH 06/16] Fix shellcheck --- src/scripts/install-python.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 4663272..fc28f96 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -1,12 +1,14 @@ #!/bin/bash PARAM_VERSION="$(echo "${PARAM_VERSION}" | circleci env subst)" -IFS='.' +IFS='.' +# shellcheck disable=SC2034 # Unused variables left for readability read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" Install_Pyenv() { curl https://pyenv.run | bash echo "export PATH=$HOME/.pyenv/bin:$PATH" >> "$BASH_ENV" - . "$BASH_ENV" + touch "${BASH_ENV}" + . "${BASH_ENV}" } Install_Python() { From 5275c93ede68f3a7ef735e39ad41c61d4c2358eb Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 11:40:39 -0500 Subject: [PATCH 07/16] Fix shellcheck --- src/scripts/install-python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index fc28f96..7c341ea 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -7,7 +7,7 @@ read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" Install_Pyenv() { curl https://pyenv.run | bash echo "export PATH=$HOME/.pyenv/bin:$PATH" >> "$BASH_ENV" - touch "${BASH_ENV}" + #shellcheck disable=SC1090 . "${BASH_ENV}" } From b259820b3b3037a4f07df153128732e5ca5a8b74 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 11:53:32 -0500 Subject: [PATCH 08/16] Fix env --- src/scripts/install-python.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 7c341ea..54ad8d1 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -1,14 +1,17 @@ #!/bin/bash +# shellcheck disable=SC2034 # Unused variables left for readability +# shellcheck disable=SC1090 PARAM_VERSION="$(echo "${PARAM_VERSION}" | circleci env subst)" IFS='.' -# shellcheck disable=SC2034 # Unused variables left for readability read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" Install_Pyenv() { - curl https://pyenv.run | bash echo "export PATH=$HOME/.pyenv/bin:$PATH" >> "$BASH_ENV" - #shellcheck disable=SC1090 + echo "export PYENV_ROOT=$HOME/.pyenv" >> "$BASH_ENV" + echo "export PYTHON_VERSION=$PARAM_VERSION" >> "$BASH_ENV" + echo "export PIPENV_DEFAULT_PYTHON_VERSION=$PARAM_VERSION" >> "$BASH_ENV" . "${BASH_ENV}" + curl https://pyenv.run | bash } Install_Python() { From f103310fd6dbbf34f49e5f89b05d0a2b9a4e837f Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 11:59:28 -0500 Subject: [PATCH 09/16] Fix shellcheck --- src/scripts/install-python.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 54ad8d1..3739c9c 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -6,10 +6,13 @@ IFS='.' read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" Install_Pyenv() { - echo "export PATH=$HOME/.pyenv/bin:$PATH" >> "$BASH_ENV" - echo "export PYENV_ROOT=$HOME/.pyenv" >> "$BASH_ENV" - echo "export PYTHON_VERSION=$PARAM_VERSION" >> "$BASH_ENV" - echo "export PIPENV_DEFAULT_PYTHON_VERSION=$PARAM_VERSION" >> "$BASH_ENV" + + { + echo "export PATH=$HOME/.pyenv/bin:$PATH" + echo "export PYENV_ROOT=$HOME/.pyenv" + echo "export PYTHON_VERSION=$PARAM_VERSION" + echo "export PIPENV_DEFAULT_PYTHON_VERSION=$PARAM_VERSION" + } >> "$BASH_ENV" . "${BASH_ENV}" curl https://pyenv.run | bash } From cedbbe40c4bdb0cab7b5bf81fe57741c54237e9f Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 13:40:18 -0500 Subject: [PATCH 10/16] Add some small fixes --- src/scripts/install-python.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 3739c9c..7cf7aa5 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -8,13 +8,13 @@ read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" Install_Pyenv() { { - echo "export PATH=$HOME/.pyenv/bin:$PATH" echo "export PYENV_ROOT=$HOME/.pyenv" + echo "export PATH=$PYENV_ROOT/bin:$PATH" echo "export PYTHON_VERSION=$PARAM_VERSION" echo "export PIPENV_DEFAULT_PYTHON_VERSION=$PARAM_VERSION" } >> "$BASH_ENV" - . "${BASH_ENV}" curl https://pyenv.run | bash + . "${BASH_ENV}" } Install_Python() { @@ -35,13 +35,13 @@ else fi if [ -z "$MAJOR" ] || [ -z "$MINOR" ]; then - echo "The version provide: $PARAM_VERSION is not valid" + echo "The version provided: $PARAM_VERSION is not valid" exit 1 fi -if ! command -v "python$MAJOR.$MINOR" >/dev/null 2>&1; then +if ! python --version | grep "Python $PARAM_VERSION" >/dev/null 2>&1; then Install_Python else - echo "Python$MAJOR.$MINOR is already installed" + echo "Python$PARAM_VERSION is already installed" exit 0 fi From d995bc33e1216dbe5433696ad26d569d7c450fe5 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 13:47:42 -0500 Subject: [PATCH 11/16] Add test with ruby executor --- .circleci/test-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index a15482b..cf19327 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -27,6 +27,9 @@ executors: docker-latest: docker: - image: cimg/base:stable + ruby: + docker: + - image: circleci/ruby:2.7.2 jobs: install-python: parameters: @@ -165,7 +168,7 @@ workflows: matrix: alias: install-python parameters: - executor: ["machine", "machine-arm","macos", "docker-latest", "python"] + executor: ["machine", "machine-arm","macos", "ruby", "python"] version: ["3.11", "3.8", "3.12", "3.11.5", "3.9.4"] post-steps: - run: From 91a3761e90fea2a625bfc34930435b039267f146 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 17 Oct 2024 13:53:42 -0500 Subject: [PATCH 12/16] Add test with ruby executor --- src/scripts/install-python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index 7cf7aa5..d555f95 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -13,8 +13,8 @@ Install_Pyenv() { echo "export PYTHON_VERSION=$PARAM_VERSION" echo "export PIPENV_DEFAULT_PYTHON_VERSION=$PARAM_VERSION" } >> "$BASH_ENV" - curl https://pyenv.run | bash . "${BASH_ENV}" + curl https://pyenv.run | bash } Install_Python() { From 532ada5cd82fdf1da562053273370e2686f5b07d Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Fri, 18 Oct 2024 08:48:37 -0500 Subject: [PATCH 13/16] Use no circleci image --- .circleci/test-deploy.yml | 2 +- src/scripts/install-python.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index cf19327..0a5da9e 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -29,7 +29,7 @@ executors: - image: cimg/base:stable ruby: docker: - - image: circleci/ruby:2.7.2 + - image: ubuntu:22.04 jobs: install-python: parameters: diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index d555f95..da262e8 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -9,11 +9,11 @@ Install_Pyenv() { { echo "export PYENV_ROOT=$HOME/.pyenv" - echo "export PATH=$PYENV_ROOT/bin:$PATH" + echo "export PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH" echo "export PYTHON_VERSION=$PARAM_VERSION" echo "export PIPENV_DEFAULT_PYTHON_VERSION=$PARAM_VERSION" } >> "$BASH_ENV" - . "${BASH_ENV}" + . "$BASH_ENV" curl https://pyenv.run | bash } From 9d7fbd03ad7066086c644fe639708481be7a5d7b Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Fri, 18 Oct 2024 10:11:45 -0500 Subject: [PATCH 14/16] Use pyenv with absolute path --- .circleci/test-deploy.yml | 2 +- src/scripts/install-python.sh | 37 +++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 0a5da9e..cf19327 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -29,7 +29,7 @@ executors: - image: cimg/base:stable ruby: docker: - - image: ubuntu:22.04 + - image: circleci/ruby:2.7.2 jobs: install-python: parameters: diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index da262e8..bdd9e10 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -5,8 +5,37 @@ PARAM_VERSION="$(echo "${PARAM_VERSION}" | circleci env subst)" IFS='.' read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" -Install_Pyenv() { +detect_os() { + detected_platform="$(uname -s | tr '[:upper:]' '[:lower:]')" + + case "$detected_platform" in + linux*) + if grep "Alpine" /etc/issue >/dev/null 2>&1; then + printf '%s\n' "Detected OS: Alpine Linux." + SYS_ENV_PLATFORM=linux_alpine + else + printf '%s\n' "Detected OS: Linux." + SYS_ENV_PLATFORM=linux + fi + ;; + darwin*) + printf '%s\n' "Detected OS: macOS." + SYS_ENV_PLATFORM=macos + ;; + msys*|cygwin*) + printf '%s\n' "Detected OS: Windows." + SYS_ENV_PLATFORM=windows + ;; + *) + printf '%s\n' "Unsupported OS: \"$detected_platform\"." + exit 1 + ;; + esac + + export SYS_ENV_PLATFORM +} +Install_Pyenv() { { echo "export PYENV_ROOT=$HOME/.pyenv" echo "export PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH" @@ -16,15 +45,15 @@ Install_Pyenv() { . "$BASH_ENV" curl https://pyenv.run | bash } - +PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Install_Python() { if ! command -v "pyenv" >/dev/null 2>&1; then Install_Pyenv else echo "Pyenv is already installed" fi - pyenv install "$PARAM_VERSION" - pyenv global "$PARAM_VERSION" + "$PYENV_ROOT/bin/pyenv" install "$PARAM_VERSION" + "$PYENV_ROOT/bin/pyenv" global "$PARAM_VERSION" echo "BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" } From 58a2bd2a7af8ea17a3e9cca054e104da2cd091ec Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Fri, 18 Oct 2024 10:47:53 -0500 Subject: [PATCH 15/16] Fix --- src/scripts/install-python.sh | 36 +++-------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index bdd9e10..a0d226f 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -5,36 +5,6 @@ PARAM_VERSION="$(echo "${PARAM_VERSION}" | circleci env subst)" IFS='.' read -r MAJOR MINOR PATCH <<< "$PARAM_VERSION" -detect_os() { - detected_platform="$(uname -s | tr '[:upper:]' '[:lower:]')" - - case "$detected_platform" in - linux*) - if grep "Alpine" /etc/issue >/dev/null 2>&1; then - printf '%s\n' "Detected OS: Alpine Linux." - SYS_ENV_PLATFORM=linux_alpine - else - printf '%s\n' "Detected OS: Linux." - SYS_ENV_PLATFORM=linux - fi - ;; - darwin*) - printf '%s\n' "Detected OS: macOS." - SYS_ENV_PLATFORM=macos - ;; - msys*|cygwin*) - printf '%s\n' "Detected OS: Windows." - SYS_ENV_PLATFORM=windows - ;; - *) - printf '%s\n' "Unsupported OS: \"$detected_platform\"." - exit 1 - ;; - esac - - export SYS_ENV_PLATFORM -} - Install_Pyenv() { { echo "export PYENV_ROOT=$HOME/.pyenv" @@ -45,15 +15,15 @@ Install_Pyenv() { . "$BASH_ENV" curl https://pyenv.run | bash } -PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + Install_Python() { if ! command -v "pyenv" >/dev/null 2>&1; then Install_Pyenv else echo "Pyenv is already installed" fi - "$PYENV_ROOT/bin/pyenv" install "$PARAM_VERSION" - "$PYENV_ROOT/bin/pyenv" global "$PARAM_VERSION" + "$HOME/.pyenv/bin/pyenv" install "$PARAM_VERSION" + "$HOME/.pyenv/bin/pyenv" global "$PARAM_VERSION" echo "BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" } From 137dcb51439393d140d8228d9da3f96d65b8ced1 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Fri, 18 Oct 2024 11:09:33 -0500 Subject: [PATCH 16/16] Revert previous change --- src/scripts/install-python.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/install-python.sh b/src/scripts/install-python.sh index a0d226f..8e9befe 100644 --- a/src/scripts/install-python.sh +++ b/src/scripts/install-python.sh @@ -22,8 +22,8 @@ Install_Python() { else echo "Pyenv is already installed" fi - "$HOME/.pyenv/bin/pyenv" install "$PARAM_VERSION" - "$HOME/.pyenv/bin/pyenv" global "$PARAM_VERSION" + pyenv install "$PARAM_VERSION" + pyenv global "$PARAM_VERSION" echo "BASH_ENV_PYTHON_ALIASED=true" >> "$BASH_ENV" }