Skip to content

Commit

Permalink
Handle circular dependencies between repos
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbidoul committed Jan 18, 2024
1 parent 43b9397 commit 594b455
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
18 changes: 13 additions & 5 deletions bin/oca_install_addons
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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

19 changes: 14 additions & 5 deletions bin/oca_list_addons_to_test_as_reqs
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 594b455

Please sign in to comment.