juftin / hatch-pip-compile

hatch plugin to use pip-compile (or uv) to manage project dependencies and lockfiles
http://juftin.com/hatch-pip-compile/
MIT License
76 stars 3 forks source link

Lockfile Out Of Date between Windows vs. Linux #58

Closed juftin closed 9 months ago

juftin commented 9 months ago

Changing between Linux and Windows makes hatch-pip-compile try to recreate the lockfile.

For some reason when running in Windows lockfile_up_to_date is False but lockfile_up_to_date is True when run on Linux.

See https://github.com/juftin/hatch-pip-compile/actions/runs/7450650936/job/20270034562 / https://github.com/juftin/hatch-pip-compile/pull/57#discussion_r1445050636

juftin commented 9 months ago

Aha! The problem is actually with lockfiles with constraints. The SHA256 of the constraint file in Windows doesn't match mac. My best guess is line endings being different here - I'll keep digging.

juftin commented 9 months ago

Yup, the issue is CLRF line endings.

This

return hashlib.sha256(self.lock_file.read_bytes()).hexdigest()

becomes this

lockfile_contents = self.lock_file.read_bytes()
cross_platform_contents = lockfile_contents.replace(b"\r\n", b"\n")
return hashlib.sha256(cross_platform_contents).hexdigest()
juftin commented 9 months ago

:tada: This issue has been resolved in version 1.9.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: