|
| 1 | +#!/bin/bash |
| 2 | +# Taken largely from https://stackoverflow.com/q/45257534 |
| 3 | +if [[ "$PYTHON_VERSION" == "2.7" ]]; then |
| 4 | + which virtualenv |
| 5 | + # Create and activate a virtualenv for conda |
| 6 | + virtualenv -p python condavenv |
| 7 | + source condavenv/bin/activate |
| 8 | + # Grab Miniconda 2 |
| 9 | + wget https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh -O miniconda.sh |
| 10 | +else |
| 11 | + # Install or upgrade to Python 3 |
| 12 | + brew update 1>/dev/null |
| 13 | + brew upgrade python |
| 14 | + # Create and activate a virtualenv for conda |
| 15 | + virtualenv -p python3 condavenv |
| 16 | + source condavenv/bin/activate |
| 17 | + # Grab Miniconda 3 |
| 18 | + wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh |
| 19 | +fi |
| 20 | + |
| 21 | +# Install our version of miniconda |
| 22 | +bash miniconda.sh -b -p $HOME/miniconda |
| 23 | +# Modify the PATH, even though this doesn't seem to be effective later on |
| 24 | +export PATH="$HOME/miniconda/bin:$PATH" |
| 25 | +hash -r |
| 26 | +# Configure conda to act non-interactively |
| 27 | +conda config --set always_yes yes --set changeps1 no |
| 28 | +# Update conda to the latest and greatest |
| 29 | +conda update -q conda |
| 30 | +# Enable conda-forge for binary packages, if necessary |
| 31 | +conda config --add channels conda-forge |
| 32 | +# Useful for debugging any issues with conda |
| 33 | +conda info -a |
| 34 | +echo "Creating conda virtualenv with Python $PYTHON_VERSION" |
| 35 | +conda create -n venv python=$PYTHON_VERSION |
| 36 | +# For whatever reason, source is not finding the activate script unless we |
| 37 | +# specify the full path to it |
| 38 | +source $HOME/miniconda/bin/activate venv |
| 39 | +# This is the Python that will be used for running tests, so we dump its |
| 40 | +# version here to help with troubleshooting |
| 41 | +which python |
| 42 | +python --version |
0 commit comments