From 2eececd70eb660b4d7b2f6435c2d471ae67366e5 Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Mon, 20 May 2024 22:24:01 +0200 Subject: [PATCH] Fix python 3.13+ --- bioimageio_chatbot/chatbot_extensions/__init__.py | 9 ++++++++- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bioimageio_chatbot/chatbot_extensions/__init__.py b/bioimageio_chatbot/chatbot_extensions/__init__.py index 2525d90..16b9217 100644 --- a/bioimageio_chatbot/chatbot_extensions/__init__.py +++ b/bioimageio_chatbot/chatbot_extensions/__init__.py @@ -1,6 +1,7 @@ import asyncio import re import pkgutil +import importlib.util from pydantic import BaseModel from bioimageio_chatbot.utils import ChatbotExtension from bioimageio_chatbot.jsonschema_pydantic import json_schema_to_pydantic_model @@ -10,7 +11,13 @@ def get_builtin_extensions(): extensions = [] for module in pkgutil.walk_packages(__path__, __name__ + '.'): if module.name.endswith('_extension'): - ext_module = module.module_finder.find_module(module.name).load_module(module.name) + if hasattr(module.module_finder, 'find_module'): + ext_module = module.module_finder.find_module(module.name).load_module(module.name) + else: + # for newer python versions, find_spec is used instead of find_module + module_spec = importlib.util.find_spec(module.name) + ext_module = importlib.util.module_from_spec(module_spec) + module_spec.loader.exec_module(ext_module) exts = ext_module.get_extension() or [] if isinstance(exts, ChatbotExtension): exts = [exts] diff --git a/pyproject.toml b/pyproject.toml index 3795a3c..807f617 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"] [project] name = "bioimageio-chatbot" -version = "0.1.98" +version = "0.1.99" readme = "README.md" description = "Your Personal Assistant in Computational BioImaging." dependencies = [