Skip to content

Commit

Permalink
fix(hatch, rye and pdm hooks): building proper sdists (#208)
Browse files Browse the repository at this point in the history
* fix(hatch hook): validate included bricks

* fix(pdm brick hook): validate included bricks

* bump hatch hook to 1.0.3

* bump pdm workspace and brick hooks to 1.0.3
  • Loading branch information
DavidVujic committed May 9, 2024
1 parent ed51bd9 commit 7eaf33b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bases/polylith/pdm_project_hooks/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def pdm_build_initialize(context):

build_dir = Path(context.build_dir)

build_initialize(context.config.data, build_dir)
build_initialize(context.config.root, context.config.data, build_dir)
13 changes: 6 additions & 7 deletions components/polylith/hatch/hooks/bricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ class PolylithBricksHook(BuildHookInterface):
PLUGIN_NAME = "polylith-bricks"

def initialize(self, _version: str, build_data: Dict[str, Any]) -> None:
pyproject = Path(f"{self.root}/{repo.default_toml}")

print(f"Using {pyproject.as_posix()}.")
root = self.root
pyproject = Path(f"{root}/{repo.default_toml}")

data = toml.read_toml_document(pyproject)
bricks = toml.get_project_packages_from_polylith_section(data)
found_bricks = {k: v for k, v in bricks.items() if Path(f"{root}/{k}").exists()}

if not bricks or not found_bricks:
return

top_ns = core.get_top_namespace(data, self.config)
work_dir = core.get_work_dir(self.config)

if not bricks:
print("No bricks found.")
return

if not top_ns:
build_data["force_include"] = bricks
return
Expand Down
11 changes: 6 additions & 5 deletions components/polylith/pdm/hooks/bricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
from polylith.pdm import core


def build_initialize(config_data: dict, build_dir: Path) -> None:
def build_initialize(root: Path, config_data: dict, build_dir: Path) -> None:
bricks = toml.get_project_packages_from_polylith_section(config_data)
top_ns = toml.get_custom_top_namespace_from_polylith_section(config_data)
work_dir = core.get_work_dir(config_data)
found_bricks = {k: v for k, v in bricks.items() if Path(root / k).exists()}

if not bricks:
print("No bricks found.")
if not bricks or not found_bricks:
return

top_ns = toml.get_custom_top_namespace_from_polylith_section(config_data)
work_dir = core.get_work_dir(config_data)

if not top_ns:
core.copy_bricks_as_is(bricks, build_dir)
else:
Expand Down
2 changes: 1 addition & 1 deletion projects/hatch_polylith_bricks/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hatch-polylith-bricks"
version = "1.2.2"
version = "1.2.3"
description = "Hatch build hook plugin for Polylith"
authors = ['David Vujic']
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Expand Down
2 changes: 1 addition & 1 deletion projects/pdm_polylith_bricks/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pdm-polylith-bricks"
version = "1.0.2"
version = "1.0.3"
description = "a PDM build hook for Polylith"
authors = ["David Vujic"]
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Expand Down
2 changes: 1 addition & 1 deletion projects/pdm_polylith_workspace/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pdm-polylith-workspace"
version = "1.0.2"
version = "1.0.3"
description = "a PDM build hook for a Polylith workspace"
homepage = "https://davidvujic.github.io/python-polylith-docs/"
repository = "https://github.com/davidvujic/python-polylith"
Expand Down

0 comments on commit 7eaf33b

Please sign in to comment.