From d0249fae9465d11b4d8a84ff2fa96df1617d1887 Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Sat, 30 Mar 2024 18:10:37 +0800 Subject: feat(doc): add support for simple package in doc --- src/ipm/api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ipm/api.py b/src/ipm/api.py index 84e389d..61f6f3a 100644 --- a/src/ipm/api.py +++ b/src/ipm/api.py @@ -578,8 +578,12 @@ def doc( project = InfiniProject(toml_path.parent) loader = Loader() loader.close() - sys.path.append(str(target_path)) - module = importlib.import_module("src") + if toml_path.parent.joinpath("src", "__init__.py").exists(): + sys.path.append(str(target_path)) + module = importlib.import_module("src") + else: + sys.path.append(str(toml_path.parent.joinpath("src"))) + module = importlib.import_module(project.name) loader.load_from_module(module) dist_path = Path(dist).resolve() dist_path.mkdir(parents=True, exist_ok=True) -- cgit v1.2.3-70-g09d2