From 2eecb7b032f61061598002cd6eb787561c046b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 16 Mar 2024 14:11:24 +0100 Subject: [PATCH] Enforce compat editable mode --- setup.py | 3 +++ setuptools_odoo/commands.py | 14 ++++++++++++++ setuptools_odoo/setup_keywords.py | 3 +++ 3 files changed, 20 insertions(+) create mode 100644 setuptools_odoo/commands.py 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):