From bdadea63b1263525fcac52dd259716c21cc4411d Mon Sep 17 00:00:00 2001 From: "Colton Wolkins (Indicio work address)" Date: Wed, 31 May 2023 10:50:33 -0600 Subject: [PATCH] fix: load package definitions based on module name Instead of relying solely on the file-path when loading a package, load from the module name instead. This should work for *most* external packages that are not installed into the ACA-Py folder. This should resolve the issue described in #2224 Signed-off-by: Colton Wolkins (Indicio work address) --- aries_cloudagent/core/util.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aries_cloudagent/core/util.py b/aries_cloudagent/core/util.py index 58b7713e8f..29b12aefdc 100644 --- a/aries_cloudagent/core/util.py +++ b/aries_cloudagent/core/util.py @@ -114,9 +114,14 @@ def get_proto_default_version(def_path: str, major_version: int = 1) -> str: def _get_path_from_msg_class(msg_class: type) -> str: path = os.path.normpath(inspect.getfile(msg_class)) split_str = os.getenv("ACAPY_HOME") or "aries_cloudagent" - path = split_str + path.rsplit(split_str, 1)[1] - version = (re.search(r"v(\d+\_)?(\*|\d+)", path)).group() - path = path.split(version, 1)[0] + try: + path = split_str + path.rsplit(split_str, 1)[1] + version = (re.search(r"v(\d+\_)?(\*|\d+)", path)).group() + path = path.split(version, 1)[0] + except: + path = msg_class.__module__ + version = (re.search(r"v(\d+\_)?(\*|\d+)", path)).group() + path = path.split(version, 1)[0] return (path.replace("/", ".")) + "definition"