|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +pyroot="$AGENT_WORKFOLDER/.venv/batchexplorer" |
| 6 | + |
| 7 | +if [ "$AGENT_OS" == "Windows_NT" ]; then |
| 8 | + # Python is already installed via a pipeline task |
| 9 | + conf_file="$pyroot/pip.ini" |
| 10 | +else |
| 11 | + conf_file="$pyroot/pip.conf" |
| 12 | + python_version=3.8.5 |
| 13 | + |
| 14 | + echo "Installing pyenv..." |
| 15 | + export PYENV_ROOT="$AGENT_WORKFOLDER/.pyenv" |
| 16 | + archive="$PYENV_ROOT/pyenv.tar.gz" |
| 17 | + mkdir -p "$PYENV_ROOT" |
| 18 | + curl -s -S -L "https://github.com/pyenv/pyenv/archive/v1.2.20.tar.gz" > "$archive" |
| 19 | + echo "5ecd10d3ec502ce9b7d8109fbe8cb2e4a8af8b73ce5c216b8e268452724a65f3 $archive" | shasum -c |
| 20 | + tar xzf "$archive" -C "$PYENV_ROOT" --strip-components=1 |
| 21 | + export PATH="$PYENV_ROOT/bin:$PATH" |
| 22 | + pyenv --version |
| 23 | + |
| 24 | + echo "Installing Python $python_version..." |
| 25 | + env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $python_version |
| 26 | + pyenv global 3.8.5 |
| 27 | + eval "$(pyenv init -)" |
| 28 | + echo "##vso[task.prependpath]$PYENV_ROOT/bin" |
| 29 | + echo "##vso[task.prependpath]$PYENV_ROOT/shims" |
| 30 | +fi |
| 31 | + |
| 32 | +echo "Setting up Python virtual environment..." |
| 33 | +python -m venv "$pyroot" |
| 34 | +if [ "$AGENT_OS" == "Windows_NT" ]; then |
| 35 | + "$pyroot/Scripts/activate" |
| 36 | +else |
| 37 | + source "$pyroot/bin/activate" |
| 38 | +fi |
| 39 | +echo "Path is $PATH" |
| 40 | + |
| 41 | +echo "Upgrading pip..." |
| 42 | +python -m pip install --upgrade pip |
| 43 | +pip install keyring artifacts-keyring |
| 44 | + |
| 45 | +echo "Configuring private feed..." |
| 46 | +# If the target conf file doesn't exist, pip config creates one at the user dir. |
| 47 | +# This doesn't matter all that much for build agents. |
| 48 | +touch "$conf_file" |
| 49 | +pip config set global.index-url https://azurebatch.pkgs.visualstudio.com/_packaging/BatchExplorer/pypi/simple/ |
| 50 | +pip config list |
0 commit comments