Skip to content

Commit

Permalink
Fix the custom build hook when using dynamic dependencies (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Mar 19, 2024
1 parent 67a4bf5 commit 04010be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions backend/src/hatchling/builders/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,15 @@ def dynamic_dependencies(self) -> list[str]:
if build_hook_cls is None:
continue

build_hook = build_hook_cls(
self.root, config, self, self.builder.metadata, '', self.builder.PLUGIN_NAME, self.builder.app
)
# Hook exists but dynamic dependencies are not imported lazily.
# This happens for example when using the `custom` build hook.
try:
build_hook = build_hook_cls(
self.root, config, self, self.builder.metadata, '', self.builder.PLUGIN_NAME, self.builder.app
)
except ImportError:
continue

dependencies.extend(build_hook.dependencies())

return dependencies
Expand Down
4 changes: 4 additions & 0 deletions docs/history/hatchling.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

***Fixed:***

- Fix the `custom` build hook when using dynamic dependencies

## [1.22.2](https://github.com/pypa/hatch/releases/tag/hatchling-v1.22.2) - 2024-03-16 ## {: #hatchling-v1.22.2 }

***Fixed:***
Expand Down

0 comments on commit 04010be

Please sign in to comment.