Skip to content

Commit

Permalink
get-requirements: --include-addons must not output local addons
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Mar 15, 2021
1 parent 60b8c77 commit f481c16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Changes
.. ----------
.. -
2.7.1 (2021-03-15)
------------------
- ``setuptools-odoo-get-requirements --include-addons`` does not output
local addons, as it is meant to list third party dependencies

2.7.0 (2021-03-13)
------------------
- [ADD] add new ``.N`` git post version strategy that adds a 6th digit with the
Expand Down
6 changes: 6 additions & 0 deletions setuptools_odoo/get_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _get_requirements(
include_addons=False,
):
requirements = set()
local_addons = set()
for addon_name in os.listdir(addons_dir):
addon_dir = os.path.join(addons_dir, addon_name)
if not is_installable_addon(addon_dir):
Expand All @@ -59,10 +60,15 @@ def _get_requirements(
# by skipping git post version lookup.
overrides["post_version_strategy_override"] = STRATEGY_NONE
metadata = get_addon_metadata(addon_dir, **overrides)
local_addons.add(metadata.get("Name"))
for install_require in metadata.get_all("Requires-Dist"):
if not include_addons and ODOO_REQ_RE.match(install_require):
continue
requirements.add(install_require)
if include_addons:
# Exclude local addons as they cannot be considered to be dependencies
# of addons in addons_dir.
requirements -= local_addons
return sorted(requirements, key=lambda s: s.lower())


Expand Down
4 changes: 1 addition & 3 deletions tests/test_get_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def test_get_requirements_include_addons(tmp_path):
"--include-addons",
]
)
assert reqs_path.read_text() == (
"odoo8-addon-addon1\nodoo>=8.0a,<9.0a\npython-dateutil\n"
)
assert reqs_path.read_text() == "odoo>=8.0a,<9.0a\npython-dateutil\n"


def test_get_requirements_header(tmp_path):
Expand Down

0 comments on commit f481c16

Please sign in to comment.