script fixes

This commit is contained in:
Ondrej Samohel 2021-09-03 19:44:10 +02:00
parent 80841fde06
commit 6d270bfeb5
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
5 changed files with 33 additions and 19 deletions

View file

@ -58,7 +58,7 @@ BICyan='\033[1;96m' # Cyan
BIWhite='\033[1;97m' # White
args=$@
disable_submodule_update = 0
disable_submodule_update=0
while :; do
case $1 in
--no-submodule-update)
@ -90,6 +90,7 @@ done
###############################################################################
detect_python () {
echo -e "${BIGreen}>>>${RST} Using python \c"
command -v python >/dev/null 2>&1 || { echo -e "${BIRed}- NOT FOUND${RST} ${BIYellow}You need Python 3.7 installed to continue.${RST}"; return 1; }
local version_command
version_command="import sys;print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"
local python_version
@ -122,7 +123,7 @@ clean_pyc () {
local path
path=$openpype_root
echo -e "${BIGreen}>>>${RST} Cleaning pyc at [ ${BIWhite}$path${RST} ] ... \c"
find "$path" -path ./build -prune -o -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
find "$path" -path ./build -o -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
echo -e "${BIGreen}DONE${RST}"
}
@ -173,7 +174,7 @@ main () {
else
echo -e "${BIYellow}NOT FOUND${RST}"
echo -e "${BIYellow}***${RST} We need to install Poetry and virtual env ..."
. "$openpype_root/tools/create_env.sh" || { echo -e "${BIRed}!!!${RST} Poetry installation failed"; return; }
. "$openpype_root/tools/create_env.sh" || { echo -e "${BIRed}!!!${RST} Poetry installation failed"; return 1; }
fi
if [ "$disable_submodule_update" == 1 ]; then
@ -184,9 +185,9 @@ if [ "$disable_submodule_update" == 1 ]; then
fi
echo -e "${BIGreen}>>>${RST} Building ..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
"$POETRY_HOME/bin/poetry" run python "$openpype_root/setup.py" build > "$openpype_root/build/build.log" || { echo -e "${BIRed}!!!${RST} Build failed, see the build log."; return; }
"$POETRY_HOME/bin/poetry" run python "$openpype_root/setup.py" build &> "$openpype_root/build/build.log" || { echo -e "${BIRed}!!!${RST} Build failed, see the build log."; return 1; }
elif [[ "$OSTYPE" == "darwin"* ]]; then
"$POETRY_HOME/bin/poetry" run python "$openpype_root/setup.py" bdist_mac > "$openpype_root/build/build.log" || { echo -e "${BIRed}!!!${RST} Build failed, see the build log."; return; }
"$POETRY_HOME/bin/poetry" run python "$openpype_root/setup.py" bdist_mac &> "$openpype_root/build/build.log" || { echo -e "${BIRed}!!!${RST} Build failed, see the build log."; return 1; }
fi
"$POETRY_HOME/bin/poetry" run python "$openpype_root/tools/build_dependencies.py"
@ -210,4 +211,6 @@ if [ "$disable_submodule_update" == 1 ]; then
echo -e "${BIWhite}$openpype_root/build${RST} directory."
}
main
return_code=0
main || return_code=$?
exit $return_code

View file

@ -88,6 +88,7 @@ done
###############################################################################
detect_python () {
echo -e "${BIGreen}>>>${RST} Using python \c"
command -v python >/dev/null 2>&1 || { echo -e "${BIRed}- NOT FOUND${RST} ${BIYellow}You need Python 3.7 installed to continue.${RST}"; return 1; }
local version_command="import sys;print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"
local python_version="$(python <<< ${version_command})"
oIFS="$IFS"
@ -125,7 +126,7 @@ clean_pyc () {
local path
path=$openpype_root
echo -e "${BIGreen}>>>${RST} Cleaning pyc at [ ${BIWhite}$path${RST} ] ... \c"
find "$path" -path ./build -prune -o -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
find "$path" -path ./build -o -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
echo -e "${BIGreen}DONE${RST}"
}
@ -166,7 +167,7 @@ main () {
echo -e "${BIGreen}OK${RST}"
else
echo -e "${BIYellow}NOT FOUND${RST}"
install_poetry || { echo -e "${BIRed}!!!${RST} Poetry installation failed"; return; }
install_poetry || { echo -e "${BIRed}!!!${RST} Poetry installation failed"; return 1; }
fi
if [ -f "$openpype_root/poetry.lock" ]; then
@ -175,7 +176,11 @@ main () {
echo -e "${BIGreen}>>>${RST} Installing dependencies ..."
fi
"$POETRY_HOME/bin/poetry" install --no-root $poetry_verbosity || { echo -e "${BIRed}!!!${RST} Poetry environment installation failed"; return; }
"$POETRY_HOME/bin/poetry" install --no-root $poetry_verbosity || { echo -e "${BIRed}!!!${RST} Poetry environment installation failed"; return 1; }
if [ $? -ne 0 ] ; then
echo -e "${BIRed}!!!${RST} Virtual environment creation failed."
return 1
fi
echo -e "${BIGreen}>>>${RST} Cleaning cache files ..."
clean_pyc
@ -184,10 +189,11 @@ main () {
# cx_freeze will crash on missing __pychache__ on these but
# reinstalling them solves the problem.
echo -e "${BIGreen}>>>${RST} Fixing pycache bug ..."
"$POETRY_HOME/bin/poetry" run python -m pip install --force-reinstall pip
"$POETRY_HOME/bin/poetry" run pip install --force-reinstall setuptools
"$POETRY_HOME/bin/poetry" run pip install --force-reinstall wheel
"$POETRY_HOME/bin/poetry" run python -m pip install --force-reinstall pip
"$POETRY_HOME/bin/poetry" run pip install --disable-pip-version-check --force-reinstall setuptools
"$POETRY_HOME/bin/poetry" run pip install --disable-pip-version-check --force-reinstall wheel
"$POETRY_HOME/bin/poetry" run python -m pip install --disable-pip-version-check --force-reinstall pip
}
main -3
return_code=0
main || return_code=$?
exit $return_code

View file

@ -32,7 +32,8 @@ main () {
openpype_version="$(python3 <<< ${version_command})"
echo -e "${BIGreen}>>>${RST} Running docker build ..."
docker build --pull --no-cache -t pypeclub/openpype:$openpype_version .
# docker build --pull --no-cache -t pypeclub/openpype:$openpype_version .
docker build --pull -t pypeclub/openpype:$openpype_version .
if [ $? -ne 0 ] ; then
echo -e "${BIRed}!!!${RST} Docker build failed."
return 1
@ -47,6 +48,7 @@ main () {
fi
echo -e "${BIYellow}---${RST} Copying ..."
docker cp "$id:/opt/openpype/build/exe.linux-x86_64-3.7" "$openpype_root/build"
docker cp "$id:/opt/openpype/build/build.log" "$openpype_root/build"
if [ $? -ne 0 ] ; then
echo -e "${BIRed}!!!${RST} Copying failed."
return 1