fix poetry on linux

This commit is contained in:
Ondrej Samohel 2021-02-05 18:27:03 +01:00
parent 35dcbce894
commit 1f419c0a83
9 changed files with 219 additions and 139 deletions

View file

@ -62,19 +62,22 @@ BIWhite='\033[1;97m' # White
# None
###############################################################################
detect_python () {
echo -e "${BIGreen}>>>${RST} Using Python \c"
local version_command
version_command="import sys;print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"
local python_version
python_version="$(python3 <<< ${version_command})"
echo -e "${BIGreen}>>>${RST} Using python \c"
local version_command="import sys;print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"
local python_version="$(python3 <<< ${version_command})"
oIFS="$IFS"
IFS=.
set -- $python_version
IFS="$oIFS"
if [ "$1" -ge "3" ] && [ "$2" -ge "6" ] ; then
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
if [ "$2" -gt "7" ] ; then
echo -e "${BIWhite}[${RST} ${BIRed}$1.$2 ${BIWhite}]${RST} - ${BIRed}FAILED${RST} ${BIYellow}Version is new and unsupported, use${RST} ${BIPurple}3.7.x${RST}"; return 1;
else
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
fi
PYTHON="python3"
else
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}FAILED${RST} ${BIYellow} Version [${RST}${BICyan}$1.$2${RST}]${BIYellow} is old and unsupported${RST}"; return 1; }
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}$1.$2$ - ${BIRed}FAILED${RST} ${BIYellow}Version is old and unsupported${RST}"; return 1; }
fi
}
@ -115,7 +118,7 @@ detect_python || return 1
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" || return > /dev/null
pushd "$pype_root" > /dev/null || return > /dev/null
version_command="import os;exec(open(os.path.join('$pype_root', 'pype', 'version.py')).read());print(__version__);"
pype_version="$(python3 <<< ${version_command})"
@ -127,8 +130,8 @@ echo -e "${BIGreen}>>>${RST} Building Pype ${BIWhite}[${RST} ${BIGreen}$pype_ver
echo -e "${BIGreen}>>>${RST} Cleaning cache files ..."
clean_pyc
echo -e "${BIGreen}>>>${RST} Building ..."
poetry run python "$pype_root/setup.py" build > "$pype_root/build/build.log"
poetry run python "$pype_root/tools/build_dependencies.py"
poetry run python3 "$pype_root/setup.py" build > "$pype_root/build/build.log"
poetry run python3 "$pype_root/tools/build_dependencies.py"
echo -e "${BICyan}>>>${RST} All done. You will find Pype and build log in \c"
echo -e "${BIWhite}$pype_root/build${RST} directory."

View file

@ -71,16 +71,21 @@ detect_python () {
set -- $python_version
IFS="$oIFS"
if [ "$1" -ge "3" ] && [ "$2" -ge "6" ] ; then
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
if [ "$2" -gt "7" ] ; then
echo -e "${BIWhite}[${RST} ${BIRed}$1.$2 ${BIWhite}]${RST} - ${BIRed}FAILED${RST} ${BIYellow}Version is new and unsupported, use${RST} ${BIPurple}3.7.x${RST}"; return 1;
else
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
fi
PYTHON="python3"
else
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}FAILED${RST} ${BIYellow} Version [${RST}${BICyan}$1.$2${RST}]${BIYellow} is old and unsupported${RST}"; return 1; }
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}$1.$2$ - ${BIRed}FAILED${RST} ${BIYellow}Version is old and unsupported${RST}"; return 1; }
fi
}
install_poetry () {
echo -e "${BIGreen}>>>${RST} Installing Poetry ..."
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
command -v curl >/dev/null 2>&1 || { echo -e "${BIRed}!!!${RST}${BIYellow} Missing ${RST}${BIBlue}curl${BIYellow} command.${RST}"; return 1; }
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
export PATH="$PATH:$HOME/.poetry/bin"
}
@ -113,32 +118,35 @@ realpath () {
echo $(cd $(dirname "$1"); pwd)/$(basename "$1")
}
# Main
echo -e "${BGreen}"
art
echo -e "${RST}"
detect_python || return 1
main () {
# Main
echo -e "${BGreen}"
art
echo -e "${RST}"
detect_python || return 1
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" || return > /dev/null
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" > /dev/null || return > /dev/null
echo -e "${BIGreen}>>>${RST} Reading Poetry ... \c"
if [ -f "$HOME/.poetry/bin/poetry" ]; then
echo -e "${BIGreen}OK${RST}"
else
echo -e "${BIYellow}NOT FOUND${RST}"
install_poetry
fi
echo -e "${BIGreen}>>>${RST} Reading Poetry ... \c"
if [ -f "$HOME/.poetry/bin/poetry" ]; then
echo -e "${BIGreen}OK${RST}"
else
echo -e "${BIYellow}NOT FOUND${RST}"
install_poetry || { echo -e "${BIRed}!!!${RST} Poetry installation failed"; return; }
fi
if [ -f "$pype_root/poetry.lock" ]; then
echo -e "${BIGreen}>>>${RST} Updating dependencies ..."
poetry update
else
echo -e "${BIGreen}>>>${RST} Installing dependencies ..."
poetry install
fi
if [ -f "$pype_root/poetry.lock" ]; then
echo -e "${BIGreen}>>>${RST} Updating dependencies ..."
poetry update || { echo -e "${BIRed}!!!${RST} Poetry environment update failed"; return; }
else
echo -e "${BIGreen}>>>${RST} Installing dependencies ..."
poetry install || { echo -e "${BIRed}!!!${RST} Poetry environment installation failed"; return; }
fi
echo -e "${BIGreen}>>>${RST} Cleaning cache files ..."
clean_pyc
echo -e "${BIGreen}>>>${RST} Cleaning cache files ..."
clean_pyc
}
main

View file

@ -70,10 +70,14 @@ detect_python () {
set -- $python_version
IFS="$oIFS"
if [ "$1" -ge "3" ] && [ "$2" -ge "6" ] ; then
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
if [ "$2" -gt "7" ] ; then
echo -e "${BIWhite}[${RST} ${BIRed}$1.$2 ${BIWhite}]${RST} - ${BIRed}FAILED${RST} ${BIYellow}Version is new and unsupported, use${RST} ${BIPurple}3.7.x${RST}"; return 1;
else
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
fi
PYTHON="python3"
else
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}FAILED${RST} ${BIYellow} Version [${RST}${BICyan}$1.$2${RST}]${BIYellow} is old and unsupported${RST}"; return 1; }
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}$1.$2$ - ${BIRed}FAILED${RST} ${BIYellow}Version is old and unsupported${RST}"; return 1; }
fi
}
@ -114,7 +118,7 @@ detect_python || return 1
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" || return > /dev/null
pushd "$pype_root" > /dev/null || return > /dev/null
echo -e "${BIGreen}>>>${RST} Generating zip from current sources ..."
poetry run python "$pype_root/start.py" generate-zip "$@"
poetry run python3 "$pype_root/start.py" generate-zip "$@"

View file

@ -71,11 +71,11 @@ echo -e "${RST}"
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" || return > /dev/null
pushd "$pype_root" > /dev/null || return > /dev/null
echo -e "${BIGreen}>>>${RST} Running apidoc ..."
poetry run sphinx-apidoc -M -e -d 10 --ext-intersphinx --ext-todo --ext-coverage --ext-viewcode -o "$pype_root/docs/source" igniter
poetry run sphinx-apidoc -M -e -d 10 --ext-intersphinx --ext-todo --ext-coverage --ext-viewcode -o "$pype_root/docs/source" pype vendor, pype\vendor
echo -e "${BIGreen}>>>${RST} Building html ..."
poetry run python "$pype_root/setup.py" build_sphinx
poetry run python3 "$pype_root/setup.py" build_sphinx

View file

@ -70,10 +70,14 @@ detect_python () {
set -- $python_version
IFS="$oIFS"
if [ "$1" -ge "3" ] && [ "$2" -ge "6" ] ; then
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
if [ "$2" -gt "7" ] ; then
echo -e "${BIWhite}[${RST} ${BIRed}$1.$2 ${BIWhite}]${RST} - ${BIRed}FAILED${RST} ${BIYellow}Version is new and unsupported, use${RST} ${BIPurple}3.7.x${RST}"; return 1;
else
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
fi
PYTHON="python3"
else
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}FAILED${RST} ${BIYellow} Version [${RST}${BICyan}$1.$2${RST}]${BIYellow} is old and unsupported${RST}"; return 1; }
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}$1.$2$ - ${BIRed}FAILED${RST} ${BIYellow}Version is old and unsupported${RST}"; return 1; }
fi
}
@ -114,8 +118,7 @@ detect_python || return 1
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" || return> /dev/null
pushd "$pype_root" > /dev/null || return > /dev/null
echo -e "${BIGreen}>>>${RST} Generating zip from current sources ..."
poetry run python "$pype_root/start.py" settings --dev
poetry run python3 "$pype_root/start.py" settings --dev

View file

@ -70,10 +70,14 @@ detect_python () {
set -- $python_version
IFS="$oIFS"
if [ "$1" -ge "3" ] && [ "$2" -ge "6" ] ; then
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
if [ "$2" -gt "7" ] ; then
echo -e "${BIWhite}[${RST} ${BIRed}$1.$2 ${BIWhite}]${RST} - ${BIRed}FAILED${RST} ${BIYellow}Version is new and unsupported, use${RST} ${BIPurple}3.7.x${RST}"; return 1;
else
echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}"
fi
PYTHON="python3"
else
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}FAILED${RST} ${BIYellow} Version [${RST}${BICyan}$1.$2${RST}]${BIYellow} is old and unsupported${RST}"; return 1; }
command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}$1.$2$ - ${BIRed}FAILED${RST} ${BIYellow}Version is old and unsupported${RST}"; return 1; }
fi
}
@ -114,7 +118,7 @@ detect_python || return 1
# Directories
pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))))
pushd "$pype_root" || return > /dev/null
pushd "$pype_root" > /dev/null || return > /dev/null
echo -e "${BIGreen}>>>${RST} Running Pype Tray with debug option ..."
poetry run python "$pype_root/start.py" tray --debug
poetry run python3 "$pype_root/start.py" tray --debug