From 863ad4f434e3df2d107bd057132b89cab0519d90 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 30 May 2021 22:27:16 -0400 Subject: [PATCH] [FIX] installation ubuntu poetry error - poetry use env python - makefile add make install to install dev - check return status in install_locally - support OCA_maintainer-tools in fresh installation --- Makefile | 3 ++ ignore_requirements.txt | 1 + pyproject.toml | 1 - script/install_debian_dependency.sh | 2 + script/install_locally.sh | 58 ++++++++++++++++++++--------- script/install_locally_dev.sh | 15 +++++++- script/install_locally_prod.sh | 9 +++++ 7 files changed, 69 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index a53694d..ca2bb35 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,9 @@ run_code_generator: ############# # INSTALL # ############# +.PHONY: install +install:install_os install_dev + .PHONY: install_dev install_dev: ./script/install_locally_dev.sh diff --git a/ignore_requirements.txt b/ignore_requirements.txt index 601982d..2c61fea 100644 --- a/ignore_requirements.txt +++ b/ignore_requirements.txt @@ -13,3 +13,4 @@ xlsxwriter ldap pythonjsonlogger python-alipay-sdk +pyrfc diff --git a/pyproject.toml b/pyproject.toml index 653ec71..12b840b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,6 @@ pymysql = "^1.0.2" pyotp = "^2.4.1" pyparsing = "2.1.10" pyproj = "^3.0.0" -pyrfc = "^0.1.2" pyserial = "3.1.1" pysftp = "^0.2.9" python-chess = "<0.24" diff --git a/script/install_debian_dependency.sh b/script/install_debian_dependency.sh index 820eee1..2dd617a 100755 --- a/script/install_debian_dependency.sh +++ b/script/install_debian_dependency.sh @@ -49,6 +49,8 @@ sudo su - postgres -c "createuser -s ${EL_USER}" 2> /dev/null || true echo -e "\n--- Installing debian dependency --" sudo apt-get install git build-essential wget libxslt-dev libzip-dev libldap2-dev libsasl2-dev libpng12-0 gdebi-core libffi-dev libbz2-dev -y sudo apt-get install libmariadbd-dev -y +# Dependencies for pyenv +sudo apt-get install make libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev -y echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----" sudo apt-get install nodejs npm -y diff --git a/script/install_locally.sh b/script/install_locally.sh index e921637..a95a0eb 100755 --- a/script/install_locally.sh +++ b/script/install_locally.sh @@ -178,13 +178,20 @@ if [[ ! -d "./addons/addons" ]]; then fi PYENV_PATH=~/.pyenv -PYENV_VERSION_PATH=${PYENV_PATH}/versions/3.7.7 +PYTHON_VERSION=3.7.7 +PYENV_VERSION_PATH=${PYENV_PATH}/versions/${PYTHON_VERSION} PYTHON_EXEC=${PYENV_VERSION_PATH}/bin/python POETRY_PATH=~/.poetry VENV_PATH=./.venv +LOCAL_PYTHON_EXEC=${VENV_PATH}/bin/python VENV_REPO_PATH=${VENV_PATH}/repo POETRY_VERSION=1.0.10 +echo "Python path version home" +echo ${PYENV_VERSION_PATH} +echo "Python path version local" +echo ${LOCAL_PYTHON_EXEC} + if [[ ! -d "${PYENV_PATH}" ]]; then echo -e "\n---- Installing pyenv in ${PYENV_PATH} ----" curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash @@ -196,28 +203,37 @@ eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" if [[ ! -d "${PYENV_VERSION_PATH}" ]]; then - echo -e "\n---- Installing python 3.7.7 with pyenv in ${PYENV_VERSION_PATH} ----" - yes n|pyenv install 3.7.7 + echo -e "\n---- Installing python ${PYTHON_VERSION} with pyenv in ${PYENV_VERSION_PATH} ----" + yes n|pyenv install ${PYTHON_VERSION} + if [[ $retVal -ne 0 ]]; then + echo "Error when installing pyenv" + exit 1 + fi fi -pyenv local 3.7.7 +pyenv local ${PYTHON_VERSION} + +if [[ ! -d ${VENV_PATH} ]]; then + echo -e "\n---- Create Virtual environment Python ----" + if [[ -e ${PYTHON_EXEC} ]]; then + ${PYTHON_EXEC} -m venv .venv + retVal=$? + if [[ $retVal -ne 0 ]]; then + echo "Virtual environment, error when creating .venv" + exit 1 + fi + else + echo "Missing pyenv, please refer installation guide." + exit 1 + fi +fi if [[ ! -d "${POETRY_PATH}" ]]; then # Delete directory ~/.poetry and .venv to force update to new version echo -e "\n---- Installing poetry for reliable python package ----" # curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | ${PYTHON_EXEC} curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py - python get-poetry.py -y --preview --version ${POETRY_VERSION} -fi - -if [[ ! -d ${VENV_PATH} ]]; then - echo -e "\n---- Create Virtual environment Python ----" - if [[ -e ${PYTHON_EXEC} ]]; then - ${PYTHON_EXEC} -m venv .venv - else - echo "Missing pyenv, please refer installation guide." - exit 1 - fi + ${LOCAL_PYTHON_EXEC} get-poetry.py -y --preview --version ${POETRY_VERSION} fi # Install git-repo if missing @@ -232,9 +248,15 @@ fi echo -e "\n---- Installing poetry dependency ----" ${VENV_PATH}/bin/pip install --upgrade pip -#/home/"${USER}"/.poetry/bin/poetry env use ${PYTHON_EXEC} -source $HOME/.poetry/env -poetry install +# Force python instead of changing env +#/home/"${USER}"/.poetry/bin/poetry env use ${LOCAL_PYTHON_EXEC} +# source $HOME/.poetry/env +${LOCAL_PYTHON_EXEC} ~/.poetry/bin/poetry install +retVal=$? +if [[ $retVal -ne 0 ]]; then + echo "Poetry installation error." + exit 1 +fi # Delete artifacts created by pip, cause error in next "poetry install" rm -rf artifacts diff --git a/script/install_locally_dev.sh b/script/install_locally_dev.sh index d5c78a9..94e39dc 100755 --- a/script/install_locally_dev.sh +++ b/script/install_locally_dev.sh @@ -3,13 +3,26 @@ . ./env_var.sh ./script/install_locally.sh +retVal=$? +if [[ $retVal -ne 0 ]]; then + echo "Error ./script/install_locally.sh" + exit 1 +fi # Update git-repo ./script/update_manifest_local_dev.sh +if [[ $retVal -ne 0 ]]; then + echo "Error manifest update, check git-repo." + exit 1 +fi # Install maintainer-tools cd script/OCA_maintainer-tools -virtualenv env +# virtualenv is not installed by default +#virtualenv env +../../.venv/bin/python -m venv env . env/bin/activate +pip install setuptools-rust python setup.py install #${VENV_PATH}/bin/pip install ./script/OCA_maintainer-tools/ +cd - diff --git a/script/install_locally_prod.sh b/script/install_locally_prod.sh index f6898d5..f3d31c5 100755 --- a/script/install_locally_prod.sh +++ b/script/install_locally_prod.sh @@ -3,6 +3,15 @@ . ./env_var.sh ./script/install_locally.sh +retVal=$? +if [[ $retVal -ne 0 ]]; then + echo "Error ./script/install_locally.sh" + exit 1 +fi # Update git-repo ./script/update_manifest_prod.sh +if [[ $retVal -ne 0 ]]; then + echo "Error manifest update, check git-repo." + exit 1 +fi