Skip to content

Commit

Permalink
Merge pull request #61 from sbidoul/ref-oca_install_addons
Browse files Browse the repository at this point in the history
Refactor oca_install_addons
  • Loading branch information
sbidoul authored Jan 19, 2024
2 parents a5f2266 + 5dd8687 commit ec902ec
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 58 deletions.
59 changes: 1 addition & 58 deletions bin/oca_install_addons
Original file line number Diff line number Diff line change
@@ -1,59 +1,2 @@
#!/bin/bash

#
# Install dependencies of addons to test, and add addons to test to Odoo's addons_path.
#
# An alternative technique would be to install all addons with `pip install --editable`
# but it is relatively slow in repos with a large number of addons. This is an area
# where pip could improve.
#

set -ex
shopt -s nullglob # in case there is setup.py nor pyproject.toml

# Compute and install direct dependencies of installable addons in $ADDONS_DIR
# (this includes addons, python external dependencies and odoo itself).
# The environment variables are for better perfomance as we are interested in
# the dependencies metadata only, and not the exact versions.
# --no-isolation is for performance. The Dockerfile has setuptools-odoo and whool
# preinstalled in the same environment as pyproject-dependencies.
# --ignore-build-errors is needed to avoid errors with uninstallable addons.
env SETUPTOOLS_ODOO_POST_VERSION_STRATEGY_OVERRIDE=none \
WHOOL_POST_VERSION_STRATEGY_OVERRIDE=none \
pyproject-dependencies \
--no-isolation \
--ignore-build-errors \
${ADDONS_DIR}/*/pyproject.toml ${ADDONS_DIR}/setup/*/setup.py \
>> test-requirements.txt
cat test-requirements.txt

# To be sure to install addons from this repo if they are dependencies of dependencies,
# we create a constraints file with local directory references to the addons to test.
if python -c 'import sys; sys.exit(sys.version_info < (3,6))' ; then
# python >= 3.6
oca_list_addons_to_test_as_reqs >> test-constraints.txt
else
# old python where pip does not support URL constraints
touch test-constraints.txt
fi
cat test-constraints.txt

# show pip config
pip config list

# Install dependencies of addons to test.
pip install -r test-requirements.txt -c test-constraints.txt

# show what we have installed
pip freeze

# Add ADDONS_DIR to addons_path.
echo "addons_path=${ADDONS_PATH},${ADDONS_DIR}" >> ${ODOO_RC}
cat ${ODOO_RC}

deps=$(oca_list_external_dependencies deb)
if [ -n "$deps" ]; then
apt-get update -qq
# Install 'deb' external dependencies of all Odoo addons found in path.
DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends ${deps}
fi
oca_install_addons__deps_and_addons_path
59 changes: 59 additions & 0 deletions bin/oca_install_addons__deps_and_addons_path
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

#
# Install dependencies of addons to test, and add addons to test to Odoo's addons_path.
#
# An alternative technique would be to install all addons with `pip install --editable`
# but it is relatively slow in repos with a large number of addons. This is an area
# where pip could improve.
#

set -ex
shopt -s nullglob # in case there is setup.py nor pyproject.toml

# Compute and install direct dependencies of installable addons in $ADDONS_DIR
# (this includes addons, python external dependencies and odoo itself).
# The environment variables are for better perfomance as we are interested in
# the dependencies metadata only, and not the exact versions.
# --no-isolation is for performance. The Dockerfile has setuptools-odoo and whool
# preinstalled in the same environment as pyproject-dependencies.
# --ignore-build-errors is needed to avoid errors with uninstallable addons.
env SETUPTOOLS_ODOO_POST_VERSION_STRATEGY_OVERRIDE=none \
WHOOL_POST_VERSION_STRATEGY_OVERRIDE=none \
pyproject-dependencies \
--no-isolation \
--ignore-build-errors \
${ADDONS_DIR}/*/pyproject.toml ${ADDONS_DIR}/setup/*/setup.py \
>> test-requirements.txt
cat test-requirements.txt

# To be sure to install addons from this repo if they are dependencies of dependencies,
# we create a constraints file with local directory references to the addons to test.
if python -c 'import sys; sys.exit(sys.version_info < (3,6))' ; then
# python >= 3.6
oca_list_addons_to_test_as_reqs >> test-constraints.txt
else
# old python where pip does not support URL constraints
touch test-constraints.txt
fi
cat test-constraints.txt

# show pip config
pip config list

# Install dependencies of addons to test.
pip install -r test-requirements.txt -c test-constraints.txt

# show what we have installed
pip freeze

# Add ADDONS_DIR to addons_path.
echo "addons_path=${ADDONS_PATH},${ADDONS_DIR}" >> ${ODOO_RC}
cat ${ODOO_RC}

deps=$(oca_list_external_dependencies deb)
if [ -n "$deps" ]; then
apt-get update -qq
# Install 'deb' external dependencies of all Odoo addons found in path.
DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends ${deps}
fi

0 comments on commit ec902ec

Please sign in to comment.