piptools.repositories.local module

class piptools.repositories.local.LocalRequirementsRepository(existing_pins: Mapping[str, InstallRequirement], proxied_repository: BaseRepository, reuse_hashes: bool = True)

Bases: BaseRepository

The LocalRequirementsRepository proxied the _real_ repository by first checking if a requirement can be satisfied by existing pins (i.e. the result of a previous compile step).

In effect, if a requirement can be satisfied with a version pinned in the requirements file, we prefer that version over the best match found in PyPI. This keeps updates to the requirements.txt down to a minimum.

_abc_impl = <_abc._abc_data object>
allow_all_wheels() → Iterator[None]

Monkey patches pip.Wheel to allow wheels from all platforms and Python versions.

clear_caches() → None

Should clear any caches used by the implementation.

property command: InstallCommand

Return an install command instance.

find_best_match(ireq: InstallRequirement, prereleases: bool | None = None) → InstallationCandidate

Returns a pinned InstallRequirement object that indicates the best match for the given InstallRequirement according to the external repository.

property finder: PackageFinder

Returns a package finder to interact with simple repository API (PEP 503)

get_dependencies(ireq: InstallRequirement) → set[InstallRequirement]

Given a pinned, URL, or editable InstallRequirement, returns a set of dependencies (also InstallRequirements, but not necessarily pinned). They indicate the secondary dependencies for the given requirement.

get_hashes(ireq: InstallRequirement, single_hash: bool = False) → set[str]

Given a pinned InstallRequirement, return a set of hashes that can be used to verify the file to install for the requirement. If single_hash is True, the set will only have the hash for the best matching file to install based on the current execution environment. When False (the default), include hashes for all of the files for a given requirement.

Files that are unhashable are excluded from the returned set.

A TypeError is raised if the given requirement is editable or unpinned.

property options: Values

Returns parsed pip options

property session: PipSession

Returns a session to make requests

piptools.repositories.local.ireq_satisfied_by_existing_pin(ireq: InstallRequirement, existing_pin: InstallationCandidate) → bool

Return True if the given InstallRequirement is satisfied by the previously encountered version pin.