From 51416e488d4802ee4e6a51cd095e62fb8523e094 Mon Sep 17 00:00:00 2001 From: Dominik Kozaczko Date: Wed, 2 Feb 2022 18:15:56 +0100 Subject: [PATCH] Utilize pakage's 'from' param for more flexible project structure. --- poetry_version_plugin/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/poetry_version_plugin/plugin.py b/poetry_version_plugin/plugin.py index 947de43..a41c360 100644 --- a/poetry_version_plugin/plugin.py +++ b/poetry_version_plugin/plugin.py @@ -27,9 +27,11 @@ def activate(self, poetry: Poetry, io: IO) -> None: raise RuntimeError(message) if version_source == "init": packages = poetry.local_config.get("packages") + package_prefix = "" if packages: if len(packages) == 1: package_name = packages[0]["include"] + package_prefix = packages[0].get("from", "") else: message = ( "poetry-version-plugin: More than one package set, " @@ -39,7 +41,7 @@ def activate(self, poetry: Poetry, io: IO) -> None: raise RuntimeError(message) else: package_name = module_name(poetry.package.name) - init_path = Path(package_name) / "__init__.py" + init_path = Path(package_prefix) / Path(package_name) / "__init__.py" if not init_path.is_file(): message = ( "poetry-version-plugin: __init__.py file not found at "