Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce compat editable mode #119

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/119.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure the setuptools ``compat`` editable mode is used when installing in PEP 660 mode.
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
Loading