From 594b455d0df9ce6af670f390f648a93c30d87502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 18 Jan 2024 16:51:26 +0100 Subject: [PATCH] Handle circular dependencies between repos When an addon on the branch being tested is also a dependency of another addon of the same repo, be sure to install the one from the current checkout, by adding constraints to the command that install dependencies. --- bin/oca_install_addons | 18 +++++++++++++----- bin/oca_list_addons_to_test_as_reqs | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/bin/oca_install_addons b/bin/oca_install_addons index a63cd41..88d8ec0 100755 --- a/bin/oca_install_addons +++ b/bin/oca_install_addons @@ -25,12 +25,21 @@ env SETUPTOOLS_ODOO_POST_VERSION_STRATEGY_OVERRIDE=none \ --ignore-build-errors \ ${ADDONS_DIR}/*/pyproject.toml ${ADDONS_DIR}/setup/*/setup.py \ >> test-requirements.txt - -# Install addons in current repo in editable mode, so coverage will see them. cat test-requirements.txt -pip install -r 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. +oca_list_addons_to_test_as_reqs >> test-constraints.txt +cat test-constraints.txt + +# show pip config pip config list -pip 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} @@ -42,4 +51,3 @@ if [ -n "$deps" ]; then # Install 'deb' external dependencies of all Odoo addons found in path. DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends ${deps} fi - diff --git a/bin/oca_list_addons_to_test_as_reqs b/bin/oca_list_addons_to_test_as_reqs index de705b2..bf9f286 100755 --- a/bin/oca_list_addons_to_test_as_reqs +++ b/bin/oca_list_addons_to_test_as_reqs @@ -11,15 +11,24 @@ import subprocess from pathlib import Path -def _make_addon_dist_name(name: str) -> str: +def _make_addon_dist_name(name): odoo_series = int(os.getenv("ODOO_VERSION").partition(".")[0]) - return f"odoo{odoo_series if odoo_series < 15 else ''}-addon-{name}" + return "odoo{odoo_series}-addon-{name}".format( + name=name, + odoo_series=odoo_series if odoo_series < 15 else "", + ) -def _make_addon_req(path: Path, editable: bool) -> str: +def _make_addon_req(path, editable): + addon_uri = path.resolve().as_uri() + addon_dist_name = _make_addon_dist_name(path.name) if editable: - return f"-e {path.resolve().as_uri()}#egg={_make_addon_dist_name(path.name)}" - return f"{_make_addon_dist_name(path.name)} @ {path.resolve().as_uri()}" + return "-e {addon_uri}#egg={addon_dist_name}".format( + addon_uri=addon_uri, addon_dist_name=addon_dist_name + ) + return "{addon_dist_name} @ {addon_uri}".format( + addon_dist_name=addon_dist_name, addon_uri=addon_uri + ) def _list_addons_to_test():