piptools.repositories.pypi module¶
- class piptools.repositories.pypi.FileStream(stream, size)¶
Bases:
NamedTuple- _asdict()¶
Return a new dict which maps field names to their values.
- _field_defaults = {}¶
- _fields = ('stream', 'size')¶
- classmethod _make(iterable)¶
Make a new FileStream object from a sequence or iterable
- _replace(**kwds)¶
Return a new FileStream object replacing specified fields with new values
- class piptools.repositories.pypi.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>¶
- _command: InstallCommand¶
- _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) 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) set[str]¶
Given an InstallRequirement, return a set of hashes that represent all of the files for a given requirement. Unhashable requirements return an empty set. Unpinned requirements raise a TypeError.
- resolve_reqs(download_dir: str | None, ireq: InstallRequirement, wheel_cache: WheelCache) set[InstallationCandidate]¶
- property session: PipSession¶
Returns a session to make requests
- piptools.repositories.pypi._get_true_base_from_index_url(url: str) str¶
Given an index URL (which may or may not end in
/simple), get the base URL for using the JSON API.Even though PyPI’s base URL is documented as
https://pypi.org/simple/, that is not the “true base URL” for using the JSON API.It is not possible to accommodate all users perfectly – we can ensure proper behavior for pypi.org and test.pypi.org , and try not to break anyone else in the process.
- piptools.repositories.pypi.candidate_version(candidate: InstallationCandidate) _BaseVersion¶
- piptools.repositories.pypi.open_local_or_remote_file(link: Link, session: Session) Iterator[FileStream]¶
Open local or remote file for reading.
- Raises:
ValueError – If link points to a local directory.
- Returns:
a context manager to a FileStream with the opened file-like object