From 366386d83e7b4e97a4215faa8a331f0a1d30fea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 5 Jul 2024 16:18:33 +0200 Subject: [PATCH 1/2] [IMP] core: remove odoo/addons/__init__.py Since this file does nothing, we can remove it and behave as a PEP 420 implicit namespace package. --- odoo/addons/__init__.py | 25 ------------------------- odoo/tools/misc.py | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 odoo/addons/__init__.py diff --git a/odoo/addons/__init__.py b/odoo/addons/__init__.py deleted file mode 100644 index 56e3bd2d8758e..0000000000000 --- a/odoo/addons/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -""" Addons module. - -This module serves to contain all Odoo addons, across all configured addons -paths. For the code to manage those addons, see odoo.modules. - -Addons are made available under `odoo.addons` after -odoo.tools.config.parse_config() is called (so that the addons paths are -known). - -This module also conveniently reexports some symbols from odoo.modules. -Importing them from here is deprecated. - -""" -# make odoo.addons a namespace package, while keeping this __init__.py -# present, for python 2 compatibility -# https://packaging.python.org/guides/packaging-namespace-packages/ -import pkgutil -import os.path -__path__ = [ - os.path.abspath(path) - for path in pkgutil.extend_path(__path__, __name__) -] diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index 5dad940be5fca..290f3cfaf04ca 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -166,7 +166,7 @@ def file_path(file_path, filter_ext=('',), env=None): :raise ValueError: if the file doesn't have one of the supported extensions (`filter_ext`) """ root_path = os.path.abspath(config['root_path']) - addons_paths = odoo.addons.__path__ + [root_path] + addons_paths = list(odoo.addons.__path__) + [root_path] if env and hasattr(env.transaction, '__file_open_tmp_paths'): addons_paths += env.transaction.__file_open_tmp_paths is_abs = os.path.isabs(file_path) From a2e4045affea902bae664ceb40a734743204cc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 5 Jul 2024 16:40:46 +0200 Subject: [PATCH 2/2] [IMP] core: use recommended pkgutil.extend_path idiom We use the recommended pkgutil.extend_path idiom from the documentation. --- odoo/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/odoo/__init__.py b/odoo/__init__.py index f9bbbb69138fc..bae8fd04b6a61 100644 --- a/odoo/__init__.py +++ b/odoo/__init__.py @@ -10,10 +10,7 @@ #---------------------------------------------------------- import pkgutil import os.path -__path__ = [ - os.path.abspath(path) - for path in pkgutil.extend_path(__path__, __name__) -] +__path__ = pkgutil.extend_path(__path__, __name__) import sys MIN_PY_VERSION = (3, 7)