#!/bin/bash # Please preserve tabs as indenting whitespace at Mario's request # to keep heredocs nice (--fe) # Use 4-character tabs to match python indent look # # **** This file should not be edited in place **** # It is maintained in a repository at # git@github.com:lsst/lsst.git # # If the file must be modified, clone the repository # and edit there. # ************************************************* # # Bootstrap lsst stack install by: # * Installing EUPS # * Installing Miniconda2 Python distribution, if necessary # * Install everything up to the lsst package # * Creating the loadLSST.xxx scripts # set -e # We want to pin this so that people can stay stable # SET FOR OFFICIAL RELEASES OTHERWISE BLANK LSST_STACK_VERSION='12.0' # # Note to developers: change these when the EUPS version we use changes # EUPS_VERSION=${EUPS_VERSION:-2.0.2} EUPS_GITREV=${EUPS_GITREV:-""} EUPS_GITREPO=${EUPS_GITREPO:-"https://github.com/RobertLuptonTheGood/eups.git"} EUPS_TARURL=${EUPS_TARURL:-"https://github.com/RobertLuptonTheGood/eups/archive/$EUPS_VERSION.tar.gz"} EUPS_PKGROOT=${EUPS_PKGROOT:-"http://sw.lsstcorp.org/eupspkg"} MINICONDA2_VERSION=${MINICONDA2_VERSION:-3.19.0.lsst4} LSST_HOME="$PWD" # canonical source for this file NEWINSTALL="https://raw.githubusercontent.com/lsst/lsst/${LSST_STACK_VERSION}/scripts/newinstall.sh" cont_flag=false batch_flag=false help_flag=false noop_flag=false # By default we use the PATH Python to bootstrap EUPS. # Set $PYTHON to override this or use the -P command line option. # $PYTHON is used to install and run EUPS and will not necessarily # be the python in the path being used to build the stack itself. PYTHON="${PYTHON:-$(which python)}" while getopts cbhnP: optflag; do case $optflag in c) cont_flag=true ;; b) batch_flag=true ;; h) help_flag=true ;; n) noop_flag=true ;; P) PYTHON=$OPTARG esac done shift $((OPTIND - 1)) if [[ "$help_flag" = true ]]; then echo echo "usage: newinstall.sh [-b] [-f] [-h] [-n] [-P ]" echo " -b -- Run in batch mode. Don't ask any questions and install all extra packages." echo " -c -- Attempt to continue a previously failed install." echo " -h -- Display this help message." echo " -n -- No-op. Go through the motions but echo commands instead of running them." echo " -P [PATH_TO_PYTHON] -- Use a specific python to bootstrap the stack." echo exit 0 fi echo echo "LSST Software Stack Builder" echo "=======================================================================" echo ########## Warn if there's a different version on the server # Don't make this fatal, it should still work for developers who are hacking their copy. set +e AMIDIFF=$(curl -L --silent $NEWINSTALL | diff --brief - $0) if [[ $AMIDIFF = *differ ]]; then echo "!!! This script differs from the recommended version for $LSST_STACK_VERSION on the distribution server." echo " If this is not intentional, get the current version from here:" echo " $NEWINSTALL" fi set -e ########## If no-op, prefix every install command with echo if [[ "$noop_flag" = true ]]; then cmd="echo" echo "!!! -n flag specified, no install commands will be really executed" else cmd="" fi ########## Refuse to run from a non-empty directory if [[ "$cont_flag" = false ]]; then if [[ ! -z "$(ls)" && ! "$(ls)" == "newinstall.sh" ]]; then echo "Please run this script from an empty directory. The LSST stack will be installed into it." exit -1; fi fi ########## Discuss the state of Git. if true; then if hash git 2>/dev/null; then GITVERNUM=$(git --version | cut -d\ -f 3) GITVER=$(printf "%02d-%02d-%02d\n" $(echo "$GITVERNUM" | cut -d. -f1-3 | tr . ' ')) fi if [[ $GITVER < "01-08-04" ]]; then if [[ "$batch_flag" != true ]]; then cat <<-EOF Detected $(git --version). The git version control system is frequently used with LSST software. While the LSST stack should build and work even in the absence of git, we don't regularly run and test it in such environments. We therefore recommend you have at least git 1.8.4 installed with your normal package manager. EOF while true; do read -p "Would you like to try continuing without git? " yn case $yn in [Yy]* ) echo "Continuing without git" break ;; [Nn]* ) echo "Okay install git and rerun the script." exit; break; ;; * ) echo "Please answer yes or no.";; esac done fi else echo "Detected $(git --version). OK." fi echo fi ########## Test/warn about Python versions, offer to get miniconda2 if too old ########## LSST currently mandates Python 2.7 and no other. ########## We assume that the python in PATH is the python that will be used to ########## build the stack if miniconda2 is not installed. if true; then PYVEROK=$(python -c 'import sys; print("%i" % (sys.hexversion >= 0x02070000 and sys.hexversion < 0x03000000))') if [[ "$batch_flag" = true ]]; then WITH_MINICONDA2=1 else if [[ $PYVEROK != 1 ]]; then cat <<-EOF LSST stack requires Python 2.7; you seem to have $(python -V 2>&1) on your path ($(which python)). Please set up a compatible python interpreter, prepend it to your PATH, and rerun this script. Alternatively, we can set up the Miniconda2 Python distribution for you. EOF fi cat <<-EOF In addition to Python 2.7, some LSST packages depend on recent versions of numpy, matplotlib, and scipy. If you don't have all of these, the installation may fail. Using the Miniconda2 Python distribution will ensure all these are set up. Miniconda2 Python installed by this installer will be managed by LSST's EUPS package manager, and will not replace or modify your system python. EOF while true; do read -p "Would you like us to install the Miniconda2 ${MINICONDA2_VERSION} Python distribution (if unsure, say yes)? " yn case $yn in [Yy]* ) WITH_MINICONDA2=1 break ;; [Nn]* ) if [[ $PYVEROK != 1 ]]; then echo echo "Thanks. After you install Python 2.7 and the required modules, rerun this script to" echo "continue the installation." echo exit fi break; ;; * ) echo "Please answer yes or no.";; esac done echo fi fi ########## Install EUPS ########## $PYTHON is the Python used to install/run EUPS. ########## It can be any Python >= v2.6 if true; then if [[ ! -x "$PYTHON" ]]; then echo -n "Cannot find or execute '$PYTHON'. Please set the PYTHON environment variable or use the -P" echo " option to point to a functioning Python >= 2.6 interpreter and rerun." exit -1; fi PYVEROK=$($PYTHON -c 'import sys; print("%i" % (sys.hexversion >= 0x02060000))') if [[ $PYVEROK != 1 ]]; then cat <<-EOF EUPS requires Python 2.6 or newer; we are using $($PYTHON -V 2>&1) from $PYTHON. Please set up a compatible python interpreter using the PYTHON environment variable or the -P command line option. EOF exit -1 fi if [[ "$PYTHON" != "/usr/bin/python" ]]; then echo "Using python at $PYTHON to install EUPS" fi if [[ -z $EUPS_GITREV ]]; then echo -n "Installing EUPS (v$EUPS_VERSION)... " else echo -n "Installing EUPS (branch $EUPS_GITREV from $EUPS_GITREPO)..." fi ( mkdir _build && cd _build if [[ -z $EUPS_GITREV ]]; then # Download tarball from github $cmd curl -L $EUPS_TARURL | tar xzvf - $cmd cd eups-$EUPS_VERSION else # Clone from git repository $cmd git clone "$EUPS_GITREPO" $cmd cd eups $cmd git checkout $EUPS_GITREV fi $cmd ./configure --prefix="$LSST_HOME"/eups --with-eups="$LSST_HOME" --with-python="$PYTHON" $cmd make install ) > eupsbuild.log 2>&1 && echo " done." || { echo " FAILED."; echo "See log in eupsbuild.log"; exit -1; } fi ########## Source EUPS set +e $cmd source "$LSST_HOME/eups/bin/setups.sh" set -e ########## Download optional component (python, git, ...) if true; then if [[ $WITH_MINICONDA2 = 1 ]]; then echo "Installing Miniconda2 Python Distribution ... " $cmd eups distrib install --repository="$EUPS_PKGROOT" miniconda2 "$MINICONDA2_VERSION" $cmd setup miniconda2 CMD_SETUP_MINICONDA2='setup miniconda2' fi fi ########## Install the Basic Environment if true; then echo "Installing the basic environment ... " $cmd eups distrib install --repository="$EUPS_PKGROOT" lsst fi ########## Create the environment loader scripts function generate_loader_bash() { file_name=$1 cat > $file_name <<-EOF # This script is intended to be used with bash to load the minimal LSST environment # Usage: source $(basename $file_name) # If not already initialized, set LSST_HOME to the directory where this script is located if [ "x\${LSST_HOME}" = "x" ]; then LSST_HOME="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" && pwd )" fi # Bootstrap EUPS EUPS_DIR="\${LSST_HOME}/eups" source "\${EUPS_DIR}/bin/setups.sh" # Setup optional packages $CMD_SETUP_MINICONDA2 $CMD_SETUP_GIT # Setup LSST minimal environment setup lsst EOF } function generate_loader_csh() { file_name=$1 cat > $file_name <<-EOF # This script is intended to be used with (t)csh to load the minimal LSST environment # Usage: source $(basename $file_name) set sourced=(\$_) if ("\${sourced}" != "") then # If not already initialized, set LSST_HOME to the directory where this script is located set this_script = \${sourced[2]} if ( ! \${?LSST_HOME} ) then set LSST_HOME = \`dirname \${this_script}\` set LSST_HOME = \`cd \${LSST_HOME} && pwd\` endif # Bootstrap EUPS set EUPS_DIR = "\${LSST_HOME}/eups" source "\${EUPS_DIR}/bin/setups.csh" # Setup optional packages $CMD_SETUP_MINICONDA2 $CMD_SETUP_GIT # Setup LSST minimal environment setup lsst endif EOF } function generate_loader_ksh() { file_name=$1 cat > $file_name <<-EOF # This script is intended to be used with ksh to load the minimal LSST environment # Usage: source $(basename $file_name) # If not already initialized, set LSST_HOME to the directory where this script is located if [ "x\${LSST_HOME}" = "x" ]; then LSST_HOME="\$( cd "\$( dirname "\${.sh.file}" )" && pwd )" fi # Bootstrap EUPS EUPS_DIR="\${LSST_HOME}/eups" source "\${EUPS_DIR}/bin/setups.sh" # Setup optional packages $CMD_SETUP_MINICONDA2 $CMD_SETUP_GIT # Setup LSST minimal environment setup lsst EOF } function generate_loader_zsh() { file_name=$1 cat > $file_name <<-EOF # This script is intended to be used with zsh to load the minimal LSST environment # Usage: source $(basename $file_name) # If not already initialized, set LSST_HOME to the directory where this script is located if [[ -z \${LSST_HOME} ]]; then LSST_HOME=\`dirname "\$0:A"\` fi # Bootstrap EUPS EUPS_DIR="\${LSST_HOME}/eups" source "\${EUPS_DIR}/bin/setups.zsh" # Setup optional packages $CMD_SETUP_MINICONDA2 $CMD_SETUP_GIT # Setup LSST minimal environment setup lsst EOF } for sfx in bash ksh csh zsh; do echo -n "Creating startup scripts ($sfx) ... " generate_loader_$sfx $LSST_HOME/loadLSST.$sfx echo "done." done ########## Helpful message about what to do next cat <<-EOF Bootstrap complete. To continue installing (and to use) the LSST stack type one of: source "$LSST_HOME/loadLSST.bash" # for bash source "$LSST_HOME/loadLSST.csh" # for csh source "$LSST_HOME/loadLSST.ksh" # for ksh source "$LSST_HOME/loadLSST.zsh" # for zsh Individual LSST packages may now be installed with the usual \`eups distrib install' command. For example, to install the science pipeline elements of the LSST stack, use: eups distrib install lsst_apps Next, read the documentation at: https://confluence.lsstcorp.org/display/LSWUG/LSST+Software+User+Guide and feel free to ask any questions via the LSST Community forum: https://community.lsst.org/c/support Also look out for our new, in development, documentation site at: https://pipelines.lsst.io Thanks! -- The LSST Software Teams http://dm.lsst.org/ EOF