Skip to content

Commit

Permalink
feat: add support for path with wildcards (#56)
Browse files Browse the repository at this point in the history
* feat: allow wildcards in project-specific package includes

* bump version to 1.5.0
  • Loading branch information
DavidVujic committed Mar 14, 2024
1 parent 8d650f9 commit 2622742
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions poetry_multiproject_plugin/components/project/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@
from poetry_multiproject_plugin.components.toml.packages import packages_to_paths


def is_relative_path(path: str) -> bool:
return str(path).startswith("..")


def copy_packages(
project_file: Path, destination: Path, top_ns: Union[str, None] = None
) -> None:
content = read.toml(project_file)
package_paths = packages_to_paths(content)

for p in package_paths:
relative_package_paths = [p for p in package_paths if is_relative_path(p["from"])]

for p in relative_package_paths:
p_from = p["from"]
p_to = p["to"]
source = Path(project_file.parent / p_from)

is_relative_path = str(p_from).startswith("..")

to = f"{top_ns}/{p_to}" if top_ns and is_relative_path else p_to
to = f"{top_ns}/{p_to}" if top_ns else p_to

to = Path(destination / to)
to_path = Path(destination / to)

shutil.copytree(
source,
to,
to_path,
ignore=shutil.ignore_patterns(
"__pycache__", ".venv", ".mypy_cache", ".git"
),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-multiproject-plugin"
version = "1.4.1"
version = "1.5.0"
description = "A Poetry plugin that makes it possible to use relative package includes."
authors = ["David Vujic"]
license = "MIT"
Expand Down

0 comments on commit 2622742

Please sign in to comment.