diff options
| author | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
|---|---|---|
| committer | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
| commit | 227b2d30a8675b44918f9d9ca89b24144a938215 (patch) | |
| tree | 9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/operations/check.py | |
| parent | 842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff) | |
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/operations/check.py')
| -rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/operations/check.py | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/operations/check.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/operations/check.py deleted file mode 100644 index bab6b9f..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/operations/check.py +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | """Validation of dependencies of packages | ||
| 2 | """ | ||
| 3 | |||
| 4 | from collections import namedtuple | ||
| 5 | |||
| 6 | from pip._vendor.packaging.utils import canonicalize_name | ||
| 7 | |||
| 8 | from pip._internal.operations.prepare import make_abstract_dist | ||
| 9 | |||
| 10 | from pip._internal.utils.misc import get_installed_distributions | ||
| 11 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING | ||
| 12 | |||
| 13 | if MYPY_CHECK_RUNNING: | ||
| 14 | from pip._internal.req.req_install import InstallRequirement | ||
| 15 | from typing import Any, Dict, Iterator, Set, Tuple, List | ||
| 16 | |||
| 17 | # Shorthands | ||
| 18 | PackageSet = Dict[str, 'PackageDetails'] | ||
| 19 | Missing = Tuple[str, Any] | ||
| 20 | Conflicting = Tuple[str, str, Any] | ||
| 21 | |||
| 22 | MissingDict = Dict[str, List[Missing]] | ||
| 23 | ConflictingDict = Dict[str, List[Conflicting]] | ||
| 24 | CheckResult = Tuple[MissingDict, ConflictingDict] | ||
| 25 | |||
| 26 | PackageDetails = namedtuple('PackageDetails', ['version', 'requires']) | ||
| 27 | |||
| 28 | |||
| 29 | def create_package_set_from_installed(**kwargs): | ||
| 30 | # type: (**Any) -> PackageSet | ||
| 31 | """Converts a list of distributions into a PackageSet. | ||
| 32 | """ | ||
| 33 | # Default to using all packages installed on the system | ||
| 34 | if kwargs == {}: | ||
| 35 | kwargs = {"local_only": False, "skip": ()} | ||
| 36 | retval = {} | ||
| 37 | for dist in get_installed_distributions(**kwargs): | ||
| 38 | name = canonicalize_name(dist.project_name) | ||
| 39 | retval[name] = PackageDetails(dist.version, dist.requires()) | ||
| 40 | return retval | ||
| 41 | |||
| 42 | |||
| 43 | def check_package_set(package_set): | ||
| 44 | # type: (PackageSet) -> CheckResult | ||
| 45 | """Check if a package set is consistent | ||
| 46 | """ | ||
| 47 | missing = dict() | ||
| 48 | conflicting = dict() | ||
| 49 | |||
| 50 | for package_name in package_set: | ||
| 51 | # Info about dependencies of package_name | ||
| 52 | missing_deps = set() # type: Set[Missing] | ||
| 53 | conflicting_deps = set() # type: Set[Conflicting] | ||
| 54 | |||
| 55 | for req in package_set[package_name].requires: | ||
| 56 | name = canonicalize_name(req.project_name) # type: str | ||
| 57 | |||
| 58 | # Check if it's missing | ||
| 59 | if name not in package_set: | ||
| 60 | missed = True | ||
| 61 | if req.marker is not None: | ||
| 62 | missed = req.marker.evaluate() | ||
| 63 | if missed: | ||
| 64 | missing_deps.add((name, req)) | ||
| 65 | continue | ||
| 66 | |||
| 67 | # Check if there's a conflict | ||
| 68 | version = package_set[name].version # type: str | ||
| 69 | if not req.specifier.contains(version, prereleases=True): | ||
| 70 | conflicting_deps.add((name, version, req)) | ||
| 71 | |||
| 72 | def str_key(x): | ||
| 73 | return str(x) | ||
| 74 | |||
| 75 | if missing_deps: | ||
| 76 | missing[package_name] = sorted(missing_deps, key=str_key) | ||
| 77 | if conflicting_deps: | ||
| 78 | conflicting[package_name] = sorted(conflicting_deps, key=str_key) | ||
| 79 | |||
| 80 | return missing, conflicting | ||
| 81 | |||
| 82 | |||
| 83 | def check_install_conflicts(to_install): | ||
| 84 | # type: (List[InstallRequirement]) -> Tuple[PackageSet, CheckResult] | ||
| 85 | """For checking if the dependency graph would be consistent after \ | ||
| 86 | installing given requirements | ||
| 87 | """ | ||
| 88 | # Start from the current state | ||
| 89 | state = create_package_set_from_installed() | ||
| 90 | _simulate_installation_of(to_install, state) | ||
| 91 | return state, check_package_set(state) | ||
| 92 | |||
| 93 | |||
| 94 | # NOTE from @pradyunsg | ||
| 95 | # This required a minor update in dependency link handling logic over at | ||
| 96 | # operations.prepare.IsSDist.dist() to get it working | ||
| 97 | def _simulate_installation_of(to_install, state): | ||
| 98 | # type: (List[InstallRequirement], PackageSet) -> None | ||
| 99 | """Computes the version of packages after installing to_install. | ||
| 100 | """ | ||
| 101 | |||
| 102 | # Modify it as installing requirement_set would (assuming no errors) | ||
| 103 | for inst_req in to_install: | ||
| 104 | dist = make_abstract_dist(inst_req).dist(finder=None) | ||
| 105 | name = canonicalize_name(dist.key) | ||
| 106 | state[name] = PackageDetails(dist.version, dist.requires()) | ||
