Work on install script
Add support for user local install Add support for already existing venv
This commit is contained in:
parent
51afffd97b
commit
42a327501e
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PYTHON_VERSION=python3
|
PYTHON=python3
|
||||||
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
||||||
DEFAULT_DEST="${HOME}/.local/share"
|
DEFAULT_DEST="${HOME}/.local/share"
|
||||||
DEFAULT_BIN="${HOME}/.local/bin"
|
DEFAULT_BIN="${HOME}/.local/bin"
|
||||||
|
@ -32,9 +32,7 @@ abort_install () {
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message () {
|
log_message () {
|
||||||
${ECHO} "================================================================================" >> ${LOGFILE}
|
|
||||||
${ECHO} "$1" >> ${LOGFILE}
|
${ECHO} "$1" >> ${LOGFILE}
|
||||||
${ECHO} "================================================================================" >> ${LOGFILE}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
|
@ -73,7 +71,7 @@ get_os () {
|
||||||
read_yes_no () {
|
read_yes_no () {
|
||||||
PROMPT="$1"
|
PROMPT="$1"
|
||||||
DEFAULT="$2"
|
DEFAULT="$2"
|
||||||
BYPASS="$3"
|
#BYPASS="$3"
|
||||||
|
|
||||||
ANSWER=""
|
ANSWER=""
|
||||||
RESPONSE=""
|
RESPONSE=""
|
||||||
|
@ -91,6 +89,8 @@ read_yes_no () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
create_folder () {
|
create_folder () {
|
||||||
FOLDER="$1"
|
FOLDER="$1"
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ create_folder () {
|
||||||
ERR_PERMS=3
|
ERR_PERMS=3
|
||||||
|
|
||||||
if ! test -d "${FOLDER}" ; then
|
if ! test -d "${FOLDER}" ; then
|
||||||
read_yes_no "The folder \"${FOLDER}\" does not exist. Should I create it" "y" "$BYPASS"
|
read_yes_no "The folder \"${FOLDER}\" does not exist. Should I create it" "y" #"$BYPASS"
|
||||||
|
|
||||||
case "${ANSWER}" in
|
case "${ANSWER}" in
|
||||||
y) mkdir -p "${FOLDER}" 2>>${LOGFILE} 1>>${LOGFILE} || return $ERR_MKDIR;;
|
y) mkdir -p "${FOLDER}" 2>>${LOGFILE} 1>>${LOGFILE} || return $ERR_MKDIR;;
|
||||||
|
@ -145,7 +145,9 @@ common_install () {
|
||||||
|
|
||||||
|
|
||||||
wrap () {
|
wrap () {
|
||||||
|
log_message "================================================================================"
|
||||||
log_message "$2"
|
log_message "$2"
|
||||||
|
log_message "================================================================================"
|
||||||
if [ "$DEBUG" = "y" ]; then
|
if [ "$DEBUG" = "y" ]; then
|
||||||
eval "($1) 2>&1" | tee -a ${LOGFILE}
|
eval "($1) 2>&1" | tee -a ${LOGFILE}
|
||||||
echo ${PIPESTATUS[0]} >${GETOUTFILE}
|
echo ${PIPESTATUS[0]} >${GETOUTFILE}
|
||||||
|
@ -176,12 +178,6 @@ local_install () {
|
||||||
${ECHO} ""
|
${ECHO} ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the destination folder
|
|
||||||
ANSWER=""
|
|
||||||
test "$BYPASS" = "y" || read -p "Please, type in the base installation folder ["${DEFAULT_DEST}"]: " "ANSWER"
|
|
||||||
DEST_FOLDER="${ANSWER:-$DEFAULT_DEST}/MsSpec-${VERSION}"
|
|
||||||
create_folder "${DEST_FOLDER}" || error_exit
|
|
||||||
export DEST_FOLDER
|
|
||||||
|
|
||||||
ANSWER=""
|
ANSWER=""
|
||||||
test "$BYPASS" = "y" || read -p "Please, type in the folder where to place the binary ["${DEFAULT_BIN}"]: " "ANSWER"
|
test "$BYPASS" = "y" || read -p "Please, type in the folder where to place the binary ["${DEFAULT_BIN}"]: " "ANSWER"
|
||||||
|
@ -189,22 +185,52 @@ local_install () {
|
||||||
create_folder "${BIN_FOLDER}" || error_exit
|
create_folder "${BIN_FOLDER}" || error_exit
|
||||||
export BIN_FOLDER
|
export BIN_FOLDER
|
||||||
|
|
||||||
# create a virtualenv
|
# If in a virtualenv, ask if we should install inside
|
||||||
# check if we are in a virtualenv and exit if so
|
|
||||||
if [ x"$VIRTUAL_ENV" != x ]; then
|
if [ x"$VIRTUAL_ENV" != x ]; then
|
||||||
${ECHO} "Installation from a previous virtualenv is not yet supported. Please deactivate it and restart the setup program." >>${LOGFILE}
|
echo "You are running a Python virtual environment"
|
||||||
error_exit
|
read_yes_no "Do you wish to install msspec inside ?" "y"
|
||||||
|
case ${ANSWER} in
|
||||||
|
y) # get the python version of this venv
|
||||||
|
v=$(python -V 2>&1 | cut -d" " -f2 | cut -d. -f1)
|
||||||
|
if [ $v -lt 3 ]; then
|
||||||
|
log_message "The Python version of this venv is < 3"
|
||||||
|
error_exit
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
n) error_exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
pip_opt=""
|
||||||
|
read_yes_no "Do you wish to create a virtual environment to install MsSpec inside" "y"
|
||||||
|
case ${ANSWER} in
|
||||||
|
y) # Create the destination folder
|
||||||
|
ANSWER=""
|
||||||
|
test "$BYPASS" = "y" || \
|
||||||
|
read -p "Please, type in the base installation folder ["${DEFAULT_DEST}"]: " "ANSWER"
|
||||||
|
DEST_FOLDER="${ANSWER:-$DEFAULT_DEST}/MsSpec-${VERSION}"
|
||||||
|
test -d $DEST_FOLDER && log_message "The folder $DEST_FOLDER already exists." && exit
|
||||||
|
create_folder "${DEST_FOLDER}" || error_exit
|
||||||
|
export DEST_FOLDER
|
||||||
|
wrap "${PYTHON} -m venv --system-site-packages --prompt=\"(msspec-${VERSION}) \" ${DEST_FOLDER}/venv" \
|
||||||
|
"Create a Python virtual environment"
|
||||||
|
. ${DEST_FOLDER}/venv/bin/activate
|
||||||
|
;;
|
||||||
|
n) pip_opt="--user"
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
wrap "virtualenv -v --python=${PYTHON_VERSION} --system-site-packages --prompt=\"(msspec-${VERSION}) \" ${DEST_FOLDER}/venv" \
|
|
||||||
"Create a Python virtual environment"
|
|
||||||
. ${DEST_FOLDER}/venv/bin/activate
|
|
||||||
|
|
||||||
# install pymsspec
|
# install pymsspec
|
||||||
wrap "make install" \
|
wrap "make sdist" \
|
||||||
|
"Building MsSpec python package"
|
||||||
|
|
||||||
|
wrap "pip install $pip_opt dist/msspec-*.tar.gz" \
|
||||||
"Installing pymsspec python package and its dependencies"
|
"Installing pymsspec python package and its dependencies"
|
||||||
|
|
||||||
# deactivate the virtualenv
|
# deactivate the virtualenv
|
||||||
deactivate
|
#if [ x"$pip_opt" = "x" ]; then
|
||||||
|
# deactivate
|
||||||
|
#fi
|
||||||
#
|
#
|
||||||
## move the frontend to the binary folder
|
## move the frontend to the binary folder
|
||||||
##wrap "mkdir -p ${LOCALBIN} && \
|
##wrap "mkdir -p ${LOCALBIN} && \
|
||||||
|
@ -217,7 +243,7 @@ local_install () {
|
||||||
#wrap "cp ./uninstall.sh ${DEST}" "Moving the uninstall script"
|
#wrap "cp ./uninstall.sh ${DEST}" "Moving the uninstall script"
|
||||||
#
|
#
|
||||||
# installation was a succes so move the logfile to the DEST directory
|
# installation was a succes so move the logfile to the DEST directory
|
||||||
wrap "cp ${LOGFILE} ${DEST_FOLDER}/msspec_install.log" "Moving the logfile"
|
#wrap "cp ${LOGFILE} ${DEST_FOLDER}/msspec_install.log" "Moving the logfile"
|
||||||
|
|
||||||
# self-explanatory
|
# self-explanatory
|
||||||
success_message
|
success_message
|
||||||
|
@ -241,9 +267,9 @@ update_path () {
|
||||||
|
|
||||||
|
|
||||||
success_message () {
|
success_message () {
|
||||||
${ECHO} "========================================================"
|
log_message "========================================================"
|
||||||
${ECHO} "MsSpec was successfully installed."
|
log_message "MsSpec was successfully installed."
|
||||||
${ECHO} "========================================================"
|
log_message "========================================================"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,12 +300,6 @@ patience () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#create_dest_folder
|
|
||||||
#echo $DEST_FOLDER
|
|
||||||
#exit
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while getopts "p:b:yd" option
|
while getopts "p:b:yd" option
|
||||||
do
|
do
|
||||||
|
@ -300,5 +320,3 @@ done
|
||||||
|
|
||||||
|
|
||||||
local_install
|
local_install
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue