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

exhaustively check `dependencies_in_sync` #50

Closed juftin closed 9 months ago

juftin commented 10 months ago

super().dependencies_in_sync() ultimately calls dependencies_in_sync on self.dependencies_complex.

https://github.com/pypa/hatch/blob/482deaddb4897b4214050dc0ca4618ae8a596f2e/src/hatch/env/virtual.py#L128-L137

    def dependencies_in_sync(self):
        if not self.dependencies:
            return True

        from hatchling.dep.core import dependencies_in_sync

        with self.safe_activation():
            return dependencies_in_sync(
                self.dependencies_complex, sys_path=self.virtual_env.sys_path, environment=self.virtual_env.environment
            )

Instead of self.dependencies_complex an exhaustive list of dependencies should be read from the requirements file. pip-tools gives a nice way to access the pip API:

from typing import Iterator, List

from piptools._compat.pip_compat import InstallRequirement, PipSession, parse_requirements

reqs: Iterator[InstallRequirement] = parse_requirements(
    "requirements.txt",
    session=PipSession(),
)
piptools_dependencies_complex: List[InstallRequirement] = list(reqs)
juftin commented 9 months ago

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

The release is available on GitHub release

Your semantic-release bot :package::rocket: