-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 dependency_hash #48
Conversation
hatch_pip_compile/plugin.py
Outdated
def dependency_hash(self) -> str: | ||
""" | ||
Get the dependency hash | ||
""" | ||
if not self.lockfile_up_to_date: | ||
self.sync_dependencies() | ||
return super().dependency_hash() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like calling lockfile_up_to_date
/ sync_dependencies
here, but I'm not sure there's a way around it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hatch's workflow:
- Check current
dependency_hash
- Compare it to stored hash
- If they don't match then run
dependencies_in_sync
/sync_dependencies
- Update the stored hash with hash from step 1
This is problematic because even though the dependency_hash
can be the same the lockfile can be completely missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This eliminates the need for dependencies_in_sync
/ sync_dependencies
to be called after dependency_hash
I've opened pypa/hatch#1168 which I think would make all of this a lot cleaner
cea69f8
to
1f97aea
Compare
82198d1
to
9b30506
Compare
Hey @oprypin could I get you to take a look at this and let me know your thoughts? EDIT: after much commit editing I've come to a conclusion that the following is the best solution. def dependency_hash(self) -> str:
"""
Get the dependency hash
"""
self.run_pip_compile()
hatch_hash = super().dependency_hash()
if not self.dependencies:
return hatch_hash
else:
lockfile_hash = self.piptools_lock.get_hash()
return hashlib.sha256(f"{hatch_hash}-{lockfile_hash}".encode()).hexdigest() The lockfile is always checked whether it's out of date - the final hash takes a SHA256 of the lockfile alongside |
7def73b
to
331b04f
Compare
331b04f
to
814a325
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked too carefully, but all solutions applied here make sense
🎉 This PR is included in version 1.8.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Resolves #47
Changes
dependency_hash
This PR implements
dependency_hash
function on the plugin which is required forhatch >= 1.8.0
. Before this fix the newdependency_hash
behavior allows for lockfiles to be out of date without getting updated because theirdependency_hash
still matches.Currently,
dependency_hash
callsrun_pip_compile
which regenerates the lockfile when needed, it then hashessuper().dependency_hash()
+ the hash of the lockfile contents.Testing
Integration Tests
CliRunner
which allows for testinghatch
CLI command with the pluginTesting Environements
The project now includes a testing matrix where hatch
1.7.x
,1.8.x
, and1.9.x
are all tested in addition to Python3.8
though3.12
.Version Pinning
After the latest tests, this plugin is found to be compatible with
hatch>=1.7.0
Lock Files
Due to above mentioned version pinning all lockfiles were regenerated - I used macOS to generate these lockfiles so some linux specific dependencies will be removed.
plugin_check_command
Wrapped with
safe_activation
to ensure it does the right thing wherever it's used