Skip to content

Commit

Permalink
Merge pull request #58 from sbidoul/circular-deps-sbi
Browse files Browse the repository at this point in the history
Handle circular dependencies between repos
  • Loading branch information
sbidoul authored Jan 19, 2024
2 parents 34dfcc2 + 08c850e commit a5f2266
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 10 deletions.
24 changes: 19 additions & 5 deletions bin/oca_install_addons
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,27 @@ 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.
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
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 +57,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

17 changes: 17 additions & 0 deletions bin/oca_list_addons_to_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

#
# Print addons to test, comma separated.
# Take INCLUDE and EXCLUDE variables into account.
# Do not list addons that are not installable.
#

set -ex

if [ -n "${INCLUDE}" ]; then
ADDONS=$(manifestoo --select-include "${INCLUDE}" --select-exclude "${EXCLUDE}" list --separator=,)
else
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} --select-exclude "${EXCLUDE}" list --separator=,)
fi

echo $ADDONS
58 changes: 58 additions & 0 deletions bin/oca_list_addons_to_test_as_reqs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python

#
# Print addons to test as pip requirements pointing to local directories.
# There is an option to make them editable or file URLs.
#

import argparse
import os
import subprocess
from pathlib import Path


def _make_addon_dist_name(name):
odoo_series = int(os.getenv("ODOO_VERSION").partition(".")[0])
return "odoo{odoo_series}-addon-{name}".format(
name=name,
odoo_series=odoo_series if odoo_series < 15 else "",
)


def _make_addon_req(path, editable):
addon_uri = path.resolve().as_uri()
addon_dist_name = _make_addon_dist_name(path.name)
if editable:
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():
return (
subprocess.check_output(["oca_list_addons_to_test"], universal_newlines=True)
.strip()
.split(",")
)


parser = argparse.ArgumentParser()
parser.add_argument(
"--editable",
action="store_true",
help="Path to addons dir",
)
args = parser.parse_args()

addons_dir = Path(os.getenv("ADDONS_DIR", "."))
for addon_name in _list_addons_to_test():
pyproject_path = addons_dir / addon_name / "pyproject.toml"
if pyproject_path.exists():
print(_make_addon_req(pyproject_path.parent, args.editable))
else:
setuppy_path = addons_dir / "setup" / addon_name / "setup.py"
if setuppy_path.exists():
print(_make_addon_req(setuppy_path.parent, args.editable))
6 changes: 1 addition & 5 deletions bin/oca_run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ set -ex

oca_wait_for_postgres

if [ -n "${INCLUDE}" ]; then
ADDONS=$(manifestoo --select-include "${INCLUDE}" --select-exclude "${EXCLUDE}" list --separator=,)
else
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} --select-exclude "${EXCLUDE}" list --separator=,)
fi
ADDONS=$(oca_list_addons_to_test)
if [ -z "$ADDONS" ]; then
exit 0
fi
Expand Down

0 comments on commit a5f2266

Please sign in to comment.