piptools.repositories package¶
Submodules¶
- piptools.repositories.base module
BaseRepositoryBaseRepository.DEFAULT_INDEX_URLBaseRepository._abc_implBaseRepository.allow_all_wheels()BaseRepository.clear_caches()BaseRepository.commandBaseRepository.find_best_match()BaseRepository.finderBaseRepository.get_dependencies()BaseRepository.get_hashes()BaseRepository.optionsBaseRepository.session
- piptools.repositories.local module
LocalRequirementsRepositoryLocalRequirementsRepository._abc_implLocalRequirementsRepository.allow_all_wheels()LocalRequirementsRepository.clear_caches()LocalRequirementsRepository.commandLocalRequirementsRepository.find_best_match()LocalRequirementsRepository.finderLocalRequirementsRepository.get_dependencies()LocalRequirementsRepository.get_hashes()LocalRequirementsRepository.optionsLocalRequirementsRepository.session
ireq_satisfied_by_existing_pin()
- piptools.repositories.pypi module
FileStreamPyPIRepositoryPyPIRepository.HASHABLE_PACKAGE_TYPESPyPIRepository._abc_implPyPIRepository._available_candidates_cachePyPIRepository._best_candidate_link()PyPIRepository._clear_finder_cache()PyPIRepository._commandPyPIRepository._dependencies_cachePyPIRepository._get_download_path()PyPIRepository._get_file_hash()PyPIRepository._get_hashes_from_pypi()PyPIRepository._get_matching_candidates()PyPIRepository._get_project()PyPIRepository._get_req_hashes()PyPIRepository._optionsPyPIRepository.allow_all_wheels()PyPIRepository.clear_caches()PyPIRepository.commandPyPIRepository.find_all_candidates()PyPIRepository.find_best_match()PyPIRepository.finderPyPIRepository.get_dependencies()PyPIRepository.get_hashes()PyPIRepository.optionsPyPIRepository.resolve_reqs()PyPIRepository.session
_get_true_base_from_index_url()candidate_version()open_local_or_remote_file()
Module contents¶
- class piptools.repositories.LocalRequirementsRepository(existing_pins: Mapping[str, InstallRequirement], proxied_repository: BaseRepository, reuse_hashes: bool = True)¶
Bases:
BaseRepositoryThe 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.
- 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 session: PipSession¶
Returns a session to make requests
- class piptools.repositories.PyPIRepository(pip_args: list[str], cache_dir: str)¶
Bases:
BaseRepository- HASHABLE_PACKAGE_TYPES = {'bdist_wheel', 'sdist'}¶
The PyPIRepository will use the provided Finder instance to lookup packages. Typically, it looks up packages on PyPI (the default implicit config), but any other PyPI mirror can be used if index_urls is changed/configured on the Finder.
- _abc_impl = <_abc._abc_data object>¶
- _best_candidate_link(ireq: InstallRequirement) Link¶
- _get_download_path(ireq: InstallRequirement) str¶
Determine the download dir location in a way which avoids name collisions.
- _get_hashes_from_pypi(ireq: InstallRequirement) dict[str, str]¶
Builds a mapping from the release URLs to their hashes as reported by the PyPI JSON API for a given InstallRequirement.
- _get_matching_candidates(ireq: InstallRequirement) set[InstallationCandidate]¶
Returns all candidates that satisfy the given InstallRequirement.
- _get_project(ireq: InstallRequirement) Any¶
Return a dict of a project info from PyPI JSON API for a given InstallRequirement. Return None on HTTP/JSON error or if a package is not found on PyPI server.
Because the JSON API is not standard, a wide class of errors are ignored in this context. Failed connections, 404s, and non-JSON responses are all treated as “no data”.
API reference: https://warehouse.readthedocs.io/api-reference/json/
- _get_req_hashes(ireq: InstallRequirement, single_hash: bool = False) set[str]¶
Collects the hashes for all candidates satisfying the given InstallRequirement. Computes the hashes for the candidates that don’t have one reported by their index.
- allow_all_wheels() Iterator[None]¶
Monkey patches pip.Wheel to allow wheels from all platforms and Python versions.
This also saves the candidate cache and set a new one, or else the results from the previous non-patched calls will interfere.
- property command: InstallCommand¶
Return an install command instance.
- find_best_match(ireq: InstallRequirement, prereleases: bool | None = None) InstallRequirement¶
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.
- resolve_reqs(download_dir: str | None, ireq: InstallRequirement, wheel_cache: WheelCache) set[InstallationCandidate]¶
- property session: PipSession¶
Returns a session to make requests