[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
This commit is contained in:
Mathieu Benoit 2021-05-30 22:27:16 -04:00
parent 6002309a68
commit 863ad4f434
7 changed files with 69 additions and 20 deletions

View file

@ -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

View file

@ -13,3 +13,4 @@ xlsxwriter
ldap
pythonjsonlogger
python-alipay-sdk
pyrfc

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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 -

View file

@ -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