Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Utilize pakage's 'from' param for more flexible project structure. #20

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion poetry_version_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
"<b>poetry-version-plugin</b>: More than one package set, "
Expand All @@ -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 = (
"<b>poetry-version-plugin</b>: __init__.py file not found at "
Expand Down