diff --git a/newsfragments/119.feature b/newsfragments/119.feature new file mode 100644 index 00000000..3227254a --- /dev/null +++ b/newsfragments/119.feature @@ -0,0 +1 @@ +Ensure the setuptools ``compat`` editable mode is used when installing in PEP 660 mode. diff --git a/setup.py b/setup.py index 16556e1d..97159d27 100644 --- a/setup.py +++ b/setup.py @@ -48,5 +48,8 @@ "odoo_addon = setuptools_odoo.setup_keywords:odoo_addon", "odoo_addons = setuptools_odoo.setup_keywords:odoo_addons", ], + "distutils.commands": [ + "editable_wheel = setuptools_odoo.commands:compat_editable_wheel", + ], }, ) diff --git a/setuptools_odoo/commands.py b/setuptools_odoo/commands.py new file mode 100644 index 00000000..a327ba2b --- /dev/null +++ b/setuptools_odoo/commands.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +try: + from setuptools.command.editable_wheel import editable_wheel +except ImportError: + compat_editable_wheel = None +else: + + class compat_editable_wheel(editable_wheel): + def initialize_options(self): + super().initialize_options() + # Enforce the "compat" editable mode which simply adds the project + # directory to sys.path with a .pth file, so Odoo will detect the addon + # in the odoo/addons directory/namespace package. + self.mode = "compat" diff --git a/setuptools_odoo/setup_keywords.py b/setuptools_odoo/setup_keywords.py index 9b5c2139..33b2e111 100644 --- a/setuptools_odoo/setup_keywords.py +++ b/setuptools_odoo/setup_keywords.py @@ -5,6 +5,7 @@ import os import warnings +from .commands import compat_editable_wheel from .core import prepare_odoo_addon, prepare_odoo_addons @@ -70,6 +71,8 @@ def odoo_addon(dist, attr, value): post_version_strategy_override=post_version_strategy_override, ) _set_dist_keywords(dist, setup_keywords) + if compat_editable_wheel is not None: + dist.cmdclass["editable_wheel"] = compat_editable_wheel def odoo_addons(dist, attr, value):