Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
installation_report.py
Go to the documentation of this file.
1from typing import Any, Dict, Sequence
2
3from pip._vendor.packaging.markers import default_environment
4
5from pip import __version__
6from pip._internal.req.req_install import InstallRequirement
7
8
10 def __init__(self, install_requirements: Sequence[InstallRequirement]):
11 self._install_requirements = install_requirements
12
13 @classmethod
14 def _install_req_to_dict(cls, ireq: InstallRequirement) -> Dict[str, Any]:
15 assert ireq.download_info, f"No download_info for {ireq}"
16 res = {
17 # PEP 610 json for the download URL. download_info.archive_info.hashes may
18 # be absent when the requirement was installed from the wheel cache
19 # and the cache entry was populated by an older pip version that did not
20 # record origin.json.
21 "download_info": ireq.download_info.to_dict(),
22 # is_direct is true if the requirement was a direct URL reference (which
23 # includes editable requirements), and false if the requirement was
24 # downloaded from a PEP 503 index or --find-links.
25 "is_direct": ireq.is_direct,
26 # requested is true if the requirement was specified by the user (aka
27 # top level requirement), and false if it was installed as a dependency of a
28 # requirement. https://peps.python.org/pep-0376/#requested
29 "requested": ireq.user_supplied,
30 # PEP 566 json encoding for metadata
31 # https://www.python.org/dev/peps/pep-0566/#json-compatible-metadata
32 "metadata": ireq.get_dist().metadata_dict,
33 }
35 # For top level requirements, the list of requested extras, if any.
36 res["requested_extras"] = list(sorted(ireq.extras))
37 return res
38
39 def to_dict(self) -> Dict[str, Any]:
40 return {
41 "version": "1",
42 "pip_version": __version__,
43 "install": [
44 self._install_req_to_dict(ireq) for ireq in self._install_requirements
45 ],
46 # https://peps.python.org/pep-0508/#environment-markers
47 # TODO: currently, the resolver uses the default environment to evaluate
48 # environment markers, so that is what we report here. In the future, it
49 # should also take into account options such as --python-version or
50 # --platform, perhaps under the form of an environment_override field?
51 # https://github.com/pypa/pip/issues/11198
52 "environment": default_environment(),
53 }
Dict[str, Any] _install_req_to_dict(cls, InstallRequirement ireq)
__init__(self, Sequence[InstallRequirement] install_requirements)
for i