Skip to content

Commit

Permalink
[IMP] use python3.8 for pre-commit-vauxoo
Browse files Browse the repository at this point in the history
Closes Vauxoo#203.

pre-commit-vauxoo requires Python 3.7 or greater to run. Some containers
in Odoo 12 and below are using Python 3.6, as a workaround, if the
Python version detected is not suitable, Python 3.8 will be installed
and used for running pre-commit-vauxoo.
  • Loading branch information
antonag32 authored and crazybolillo committed Aug 22, 2023
1 parent 72c2c18 commit 0b8c661
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/travis2docker/templates/Dockerfile_deployv
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ENV {{ build_env_arg }}=TRUE
# Create cluster with odoo as owner and use environment variables instead of odoo cfg to connect
RUN . /home/odoo/build.sh && \
install_dev_tools && \
install_pcv && \
service_postgres_without_sudo odoo odoo && \
install_pgcli_venv && \
custom_alias && \
Expand Down
30 changes: 22 additions & 8 deletions src/travis2docker/templates/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,11 @@ install_dev_tools(){
py-spy \
virtualenv \
ipdb \
pre-commit-vauxoo \
diff-highlight \
pg-activity \
nodeenv \
pdbpp

# Symlinks used by vscode and possibly other tools.
PCV_DIR="$(python3 -c "import pre_commit_vauxoo as pcv; print(pcv.__path__[0])")/cfg"
ln -sf "${PCV_DIR}/.pylintrc" "${HOME}/.pylintrc"
ln -sf "${PCV_DIR}/.flake8" "${HOME}/.flake8"
ln -sf "${PCV_DIR}/.isort.cfg" "${HOME}/.isort.cfg"
ln -sf "${PCV_DIR}/.eslintrc.json" "${HOME}/.eslintrc.json"

# pre install pre-commit-vauxoo?
# sudo su odoo -c "git init /tmp/test && cd /tmp/test && pre-commit-vauxoo -f"
touch /home/odoo/full_test-requirements.txt
Expand Down Expand Up @@ -153,6 +145,28 @@ EOF
git clone --depth 1 -b master https://github.com/Vauxoo/emacs.d.git /home/odoo/.emacs.d
}

# Ensure pre-commit-vauxoo is installed on python3.8
install_pcv() {
[[ $(python3 --version) =~ [0-9]\.([0-9]+) ]]

if ! [[ ${BASH_REMATCH[1]} -lt 7 ]]; then
printf "INFO: Using python <= 3.7, installing python3.8 for pcv\n"
PYTHON=python3.8
apt install ${PYTHON} -y
curl -sSL https://bootstrap.pypa.io/get-pip.py | ${PYTHON} -
else
PYTHON=python3
fi
${PYTHON} -m pip install pre-commit-vauxoo

# Symlinks used by vscode and possibly other tools.
PCV_DIR="$(${PYTHON} -c "import pre_commit_vauxoo as pcv; print(pcv.__path__[0])")/cfg"
ln -sf "${PCV_DIR}/.pylintrc" "${HOME}/.pylintrc"
ln -sf "${PCV_DIR}/.flake8" "${HOME}/.flake8"
ln -sf "${PCV_DIR}/.isort.cfg" "${HOME}/.isort.cfg"
ln -sf "${PCV_DIR}/.eslintrc.json" "${HOME}/.eslintrc.json"
}

setup_coverage() {
echo "export MODULES2TEST=$(cd ${MAIN_REPO_FULL_PATH} && find * -name "__manifest__.py" -printf "/%h,")" >> ${HOME}/.bashrc
echo "export MODULES2INSTALL=$(cd ${MAIN_REPO_FULL_PATH} && find * -name "__manifest__.py" -printf "%h,")" >> ${HOME}/.bashrc
Expand Down

0 comments on commit 0b8c661

Please sign in to comment.