-
Notifications
You must be signed in to change notification settings - Fork 353
Fix Python version in Ubuntu18 #979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amanr032
wants to merge
4
commits into
sodafoundation:master
Choose a base branch
from
amanr032:my_master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,114 @@ | ||
| #!/bin/bash | ||
|
|
||
| #SetupTool version to be installed | ||
| SETUPTOOL_VERSION="65.0.0" | ||
| PY_VERSION_RE='^3(\.[0-9]+)(\.[0-9])?$' | ||
|
|
||
| # Install dependencies | ||
| echo Installing dependencies | ||
| sudo apt-get install -y make curl wget libltdl7 libseccomp2 libffi-dev gawk apt-transport-https ca-certificates curl gnupg gnupg-agent lsb-release software-properties-common sshpass pv | ||
|
|
||
| echo Enabling docker repository | ||
| sudo mkdir -p /etc/apt/keyrings | ||
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes | ||
|
|
||
| echo \ | ||
| "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
| $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
|
||
| # Update local repositories | ||
| echo Updating local repositories | ||
| sudo apt-get update | ||
|
|
||
| # Install python dependencies | ||
| echo Installing Python dependencies | ||
| sudo apt-get install -y python3-distutils | ||
| sudo apt-get install -y python3-pip | ||
| python3 -m pip install -U pip setuptools | ||
|
|
||
| # Install ansible if not present | ||
| if [ "`which ansible`" != "" ]; then | ||
| function install_common_dependencies() { | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| echo Installing common dependencies | ||
| sudo apt-get install -y make curl wget libltdl7 libseccomp2 libffi-dev gawk apt-transport-https ca-certificates \ | ||
| curl gnupg gnupg-agent lsb-release software-properties-common sshpass pv | ||
|
|
||
| echo Enabling docker repository | ||
| sudo mkdir -p /etc/apt/keyrings | ||
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes | ||
|
|
||
| echo \ | ||
| "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
| $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
|
||
| # Update local repositories | ||
| echo Updating local repositories | ||
| sudo apt-get update | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| # Install Pyenv | ||
| function install_pyenv() { | ||
| if command -v pyenv 1; then | ||
| echo pyenv available | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| else | ||
| echo Installing Pyenv Dependencies | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ | ||
| libbz2-dev libreadline-dev libsqlite3-dev llvm \ | ||
| libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev | ||
| echo Downloading pyenv | ||
| curl https://pyenv.run | bash | ||
| export PATH="$HOME/.pyenv/bin:$PATH" && eval "$(pyenv init --path)" \ | ||
| && echo -e 'export PATH="$HOME/.pyenv/bin:$PATH"\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc | ||
| echo Restarting shell | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| fi | ||
| } | ||
|
|
||
| # Install Python | ||
| function install_python() { | ||
| echo Start Python $PYTHON_VERSION Installtion | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| pyenv install $PYTHON_VERSION | ||
| pyenv global $PYTHON_VERSION | ||
| echo Finish Python Installtion | ||
| } | ||
|
|
||
| #Upgrade Python if version is below than $PYTHON_VERSION | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| function upgrade_python { | ||
| PYTHON_VERSION=${1} | ||
| if [ -z $PYTHON_VERSION ] || ! [[ $PYTHON_VERSION =~ $re ]]; then | ||
| return | ||
| fi | ||
| if $(dpkg --compare-versions $(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:3])))') "lt" $PYTHON_VERSION); then | ||
| install_pyenv | ||
| install_python | ||
| fi | ||
| } | ||
|
|
||
| # Install setuptools | ||
| function install_setuptools { | ||
| IFS=' ' | ||
| v=`python3 -m pip list | grep -i setuptools | { read _ v; echo $v; }` | ||
| if $(dpkg --compare-versions $v "gt" $SETUPTOOL_VERSION); then | ||
| python3 -m pip install setuptools==65.0.0 | ||
| fi | ||
| unset IFS v | ||
| } | ||
|
|
||
|
|
||
| # Install Python Dependencies | ||
| function install_python_dependencies() { | ||
| echo Installing Python dependencies | ||
| sudo apt-get install -y python3-distutils | ||
| sudo apt-get install -y python3-pip | ||
| python3 -m pip install -U pip | ||
| install_setuptools | ||
| # Install ansible if not present | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| if [ "`which ansible`" != "" ]; then | ||
| echo ansible already installed, skipping. | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| else | ||
| else | ||
| echo Installing ansible | ||
| python3 -m pip install --user ansible | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| # Install docker if not present | ||
| if [ "`which docker`" != "" ]; then | ||
| function install_docker() { | ||
| if [ "`which docker`" != "" ]; then | ||
| echo Docker already installed, skipping. | ||
| else | ||
| else | ||
| echo Installing docker | ||
| sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin | ||
| fi | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
|
|
||
| function main() { | ||
| install_common_dependencies | ||
| upgrade_python ${1} | ||
| install_python_dependencies | ||
| install_docker | ||
| Ensure /usr/local/bin is in path | ||
|
amanr032 marked this conversation as resolved.
Outdated
|
||
| export PATH=$PATH:/usr/local/bin | ||
| } | ||
|
|
||
|
|
||
| # Ensure /usr/local/bin is in path | ||
| export PATH=$PATH:/usr/local/bin | ||
| # Entry point. START | ||
| main ${1} | ||
| exec $SHELL | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.