Skip to content

Commit

Permalink
Enforce compat editable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Mar 16, 2024
1 parent bac701c commit 2eecb7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
},
)
14 changes: 14 additions & 0 deletions setuptools_odoo/commands.py
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions setuptools_odoo/setup_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import warnings

from .commands import compat_editable_wheel
from .core import prepare_odoo_addon, prepare_odoo_addons


Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 2eecb7b

Please sign in to comment.