Skip to content

Fix hook deps not being installed#2225

Open
cobaltt7 wants to merge 4 commits intopypa:masterfrom
cobaltt7:gh-2110-2139
Open

Fix hook deps not being installed#2225
cobaltt7 wants to merge 4 commits intopypa:masterfrom
cobaltt7:gh-2110-2139

Conversation

@cobaltt7
Copy link
Copy Markdown

@cobaltt7 cobaltt7 commented Mar 30, 2026

Fixes #2139
Fixes #2110
Superseeds & closes #2206

I didn't notice #2206 had been raised until after I had finished manually debugging myself, but thought I might as well open my own PR. This is an alternate fix to #2206 that retains the performance benefits of using cached_property.

The issue was that additional_dependencies hadn't been found yet when prepare_environment was called, so they didn't end up in the cached all_dependencies_complex. I fixed the issue by moving the prepare_environment call to after additional_dependencies is set.

I would greatly appreciate it if this is merged & released soon, as I'm sure many others would be too, as this is blocking me from upgating beyond hatch 1.15.1 (and by extension, beyond virtualenv 20.39.1).

I'd appreciate guidance creating tests if they're desired. I'm not sure what the best way to go about it is - the other PR linked seems to do it a bit roundabout by creating temp dirs

(No AI was used with this PR)

Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
with self.build_env.app_status_dependency_synchronization():
self.build_env.sync_dependencies()

self.prepare_environment(self.build_env, keep_env=keep_env)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be before the context manager that handles dependency synchronization most likely.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I don't think the first if additional_dependencies is necessary still, but I kept it in case of any potential performance benefits (I'm unaware if there actually are any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hatch build stopped working with hooks in 1.16.0 Regression: hatch fails on import in build hook with require-runtime-dependencies

2 participants