From 07e1fd31dd7dd20dcb505c458735e7b611debd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 9 May 2010 01:09:36 +0200 Subject: [PATCH] Try to find module in sys.path before using dirname of ep.dist.location (transplanted from 721eafa7463056c92c58410187255621da7174e9) --- trytond/modules/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index 62dbc348f3..f1b27a9dae 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -382,9 +382,16 @@ def register_classes(reload_p=False): mod_path = os.path.join(ep.dist.location, *ep.module_name.split('.')[:-1]) if not os.path.isdir(mod_path): - # When testing modules from setuptools location is the module - # directory - mod_path = os.path.dirname(ep.dist.location) + # Find module in path + for path in sys.path: + mod_path = os.path.join(path, + *ep.module_name.split('.')[:-1]) + if os.path.isdir(os.path.join(mod_path, module)): + break + if not os.path.isdir(os.path.join(mod_path, module)): + # When testing modules from setuptools location is the + # module directory + mod_path = os.path.dirname(ep.dist.location) mod_file, pathname, description = imp.find_module(module, [mod_path]) try: