From fc5368eb516f9f8ee582d66555e7a4c491f16ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 27 Sep 2023 09:37:07 +0200 Subject: [PATCH] Use __file__ attribute of loaded module for egg modules Since pip >= 23, the Distribution location does not point to the development directory. Closes #12582 --- trytond/trytond/tools/misc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/trytond/trytond/tools/misc.py b/trytond/trytond/tools/misc.py index 79900f058a..1bb1d87e87 100644 --- a/trytond/trytond/tools/misc.py +++ b/trytond/trytond/tools/misc.py @@ -48,7 +48,8 @@ def find_path(name, subdir='modules', _test=os.path.isfile): module_name = name.split(os.sep)[0] if module_name in EGG_MODULES: epoint = EGG_MODULES[module_name] - mod_path = os.path.join(epoint.dist.location, + location = os.path.dirname(epoint.load().__file__) + mod_path = os.path.join(location, *epoint.module_name.split('.')[:-1]) mod_path = os.path.abspath(mod_path) egg_name = secure_join(mod_path, name) @@ -65,7 +66,7 @@ def find_path(name, subdir='modules', _test=os.path.isfile): # When testing modules from setuptools location is the # module directory egg_name = secure_join( - os.path.dirname(epoint.dist.location), name) + os.path.dirname(location), name) if subdir: if (subdir == 'modules'