1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
Commit graph

121 commits

Author SHA1 Message Date
Pradyun Gedam
997c5a742b
Merge pull request #10625 from albertosottile/ignore_yanked 2022-01-24 23:47:54 +00:00
Alberto Sottile
705742337d Implement suggested changes 2021-11-07 21:26:12 +01:00
Alberto Sottile
d1ba9d519e Fix permissions 2021-11-07 11:36:52 +01:00
Alberto Sottile
8293826bf0 Change specifier detection logic to exclude compatible release clauses 2021-11-06 16:24:00 +01:00
Ed Morley
cfbdc48635
Update the docs URL shown for ResolutionImpossible errors
Previously the `ResolutionImpossible` error message referenced:
https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

However that section was moved in #10279, to:
https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Updating the URL not only saves a click, but also saves having to find the related
content halfway-down the dependency resolution page, since the forwarding link 
was to the top of the page rather than the specific section.
2021-11-03 09:38:27 +00:00
Alberto Sottile
6b62c28060 Skip yanked releases unless specified 2021-10-30 11:40:40 +02:00
Alex Hedges
e1f81bfa4d Fix many typos 2021-10-11 15:48:17 -04:00
Joseph Bylund
dee6690f06 Renames, moves, docstrings, comments 2021-10-07 07:11:33 -04:00
Joseph Bylund
bd87828eae (joe) black + imports 2021-10-06 12:48:48 -04:00
Joseph Bylund
bb8824439e (joe) requirement creation is very expensive, and at least in my test case there were only ~200 unique requirement objects created in ~5-10 minutes of resolution time 2021-10-06 12:42:44 -04:00
Jon Dufresne
60c274be2d Complete type annotations of tests/unit/ directory 2021-09-23 05:44:54 -07:00
Tzu-ping Chung
135faabfd6
Remove direct pkg_resource usages from resolver and preparer 2021-08-23 02:07:33 +08:00
Tzu-ping Chung
d4d2445350 Remove get_installed_distributions usages
The function itself is kept for now because it's currently used to test
the pip.metadata subpackage...
2021-07-22 23:22:12 +08:00
Tzu-ping Chung
73edd74c56 Detect user-requested package names by preparing
This always prepares each explicit requirements when the resolver is
run, instead of when they are being resolved. But we always want to
prepare them anyway (an explicit requirement has only one candidate, so
it's either do or die), so this is not really a problem.
2021-07-12 12:40:34 +08:00
Tzu-ping Chung
5d81040ee8 Refactor root requirement collection into factory 2021-07-12 12:40:32 +08:00
Harutaka Kawamura
72e1ff35c7
Complete type annotations in pip/_internal/resolution (#10125) 2021-07-12 11:41:48 +08:00
briantracy
37a2b12a21
Special case warning for requirements.txt install (#9915)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-07-12 11:40:43 +08:00
Tzu-ping Chung
d18ac6250e Exclude a known incompatible installed candidate
The resolver collects previously known incompatibilites and sends them
to the provider. But previously the provider does not correctly exclude
the currently-installed candidate if it is present in that
incompatibility list, causing the resolver to enter a loop trying that
same candidate. This patch correctly applies incompat_ids when producing
an AlreadyInstalledCandidate and exclude it if its id() is in the set.
2021-05-18 23:00:25 +08:00
Tzu-ping Chung
cf4e3aa055 Remove stray id(candidate) call
Also moves the incompatibility candidate calculation to closer to their
usages.
2021-04-24 02:09:24 +08:00
Tzu-ping Chung
9cab9834fa Refactor Factory.find_candidates() for readability 2021-04-19 12:21:35 +08:00
Tzu-ping Chung
0305e0d596 Implement extra-ed requirement merging
When a requirement is requested multiple times, some via a direct URL
("req @ URL") and some not but with extras ("req[extra] VERSION"), the
resolver previous could not correctly find "req[extra]" if "req" is
available in an index.

This additional logic makes the resolver, when encountering a
requirement with identifier "req[extra]", to also look for explicit
candidates listed under "req", and add them as found matches for
"req[extra]".
2021-04-19 08:37:35 +08:00
Stéphane Bidoul
8fc65ea53f
Merge pull request #9673 from mwchase/url-constraints-final-2
Support URL constraints in the new resolver
2021-04-18 12:31:45 +02:00
Max W Chase
4c69ab2a2c Support URL constraints in the new resolver
Fixes #8253
2021-04-17 07:59:57 -04:00
Tzu-ping Chung
4e56f1c52d Take responsibility to remove incompatibilities 2021-04-04 20:39:28 +08:00
Tzu-ping Chung
9ceabb568f Add note to explain the cast 2021-04-03 16:25:38 +08:00
Tzu-ping Chung
0d39ae9734 Pull in resolvelib's typing information 2021-04-03 16:25:38 +08:00
Andrey Bienkowski
622f104694 Use f-strings for formatting
suggested by pyupgrade --py36-plus
2021-03-30 15:48:27 +03:00
Tzu-ping Chung
56a8f3d8bd Typing fixes 2021-03-10 16:40:58 +08:00
Tzu-ping Chung
80e0163e03
Merge pull request #9552
From uranusjr/new-resolver-requires-python-error
2021-03-08 02:26:20 +08:00
Blazej Michalik
d1d914597c
Refactor set(...){...}
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-02-28 00:41:04 +01:00
Tzu-ping Chung
d87abdfdfe Fix error reporting on Requires-Python conflicts 2021-02-28 07:31:39 +08:00
Blazej Michalik
a2c57948b6 Bring back the "from versions:" message
In the new resolver the "(from versions ...)" message, shown on
failure to resolve a package, has been removed. This commit brings it
back.
2021-02-27 20:37:10 +01:00
Tzu-ping Chung
917ecadd77 Show constraint in error message 2021-02-23 02:08:19 +08:00
Jon Dufresne
8a6f6ac19b Blacken src/pip/_internal/resolution directory 2021-02-20 06:51:44 -08:00
Jon Dufresne
0945809afc Remove typing.TYPE_CHECKING guards
The typing module has been available since Python 3.5. Guarding the
import has been unnecessary since dropping Python 2.

Some guards remain to either:

- Avoid circular imports
- Importing objects that are also guarded by typing.TYPE_CHECKING
- Avoid mypy_extensions dependency
2021-02-19 18:34:21 -08:00
Jon Dufresne
a6392bd62e Replace pip._internal.utils.typing with stdlib typing
The stdlib module has been available since Python 3.5 and the
TYPE_CHECKING constant has been available since 3.5.2.

By using stdlib, this removes the need for pip to maintain its own
Python 2 typing compatibility shim.
2021-02-18 19:09:13 -08:00
Tzu-ping Chung
2e70ec0751 Create the candidate lazily to avoid download 2021-01-27 19:58:24 +08:00
Tzu-ping Chung
79cbe6b93f Avoid downloading candidates of a same version
Since 41a30089de, Candidate objects prepare their underlying
distribution eagerly on creation, so the error can be caught
deterministically to trigger backtracking.

This however has a negative side-effect. Since dist preparation involves
metadata validation, a remote distribution must be downloaded on
Candidate creation. This means that an sdist will be downloaded,
validated, and discarded (since its version is known to be incompatible)
during backtracking.

This commit moves version deduplication of candidates from indexes to
before the Candidate object is created, to avoid unneeded preparation.

Note that we still need another round of deduplication in FoundCandidates
to remove duplicated candidates when a distribution is already installed.
2021-01-06 17:19:59 +08:00
Jon Dufresne
133e146a88 Remove unused type VersionCandidate
Unused since 6a8956d7a8.
2020-12-28 19:18:20 -08:00
Tzu-ping Chung
41a30089de Re-apply invalid metadata skip
Skip candidate not providing valid metadata

This reverts commit 7165ab8cb9.
2020-12-27 04:16:24 +08:00
Pradyun Gedam
86afa89043
Merge pull request #9361 from jdufresne/f-strings
Use f-strings for simple string formatting
2020-12-26 10:24:18 +00:00
Jon Dufresne
cdcf74fb8e Use f-strings for simple string formatting
Use pyupgrade to convert simple string formatting to use f-string
syntax. pyupgrade is intentionally timid and will not create an f-string
if it would make the expression longer or if the substitution parameters
are anything but simple names or dotted names.
2020-12-25 16:21:20 -08:00
Jon Dufresne
09b3d3a50b Remove object from class definitions
Unnecessary since dropping Python 2 support. In Python 3, all classes
are new style classes.
2020-12-25 15:48:11 -08:00
Pradyun Gedam
7165ab8cb9
Revert "Skip candidate not providing valid metadata" 2020-12-15 10:17:20 +00:00
Tzu-ping Chung
d869e0cbfd Merge master 2020-12-12 18:49:14 +08:00
Tzu-ping Chung
b2c04877fa Add comments explaining InstallationError handling 2020-12-12 18:47:37 +08:00
Tzu-ping Chung
120105d3e8 Cache AlreadyInstalledCandidate
Since the "Requirement already satisfied" message is printed during
candidate preparation, instantiating the candidate multiple times result
in excessive logging during intensive backtracking. By caching the
already-installed candidates, each package is only prepared, and thus
only logged once.
2020-12-12 02:39:54 +08:00
Tzu-ping Chung
d45541c8f3 Skip candidate not providing valid metadata
This is done by catching InstallationError from the underlying
distribution preparation logic. There are three cases to catch:

1. Candidates from indexes. These are simply ignored since we can
   potentially satisfy the requirement with other candidates.
2. Candidates from URLs with a dist name (PEP 508 or #egg=). A new
   UnsatisfiableRequirement class is introduced to represent this; it is
   like an ExplicitRequirement without an underlying candidate. As the
   name suggests, an instance of this can never be satisfied, and will
   cause eventual backtracking.
3. Candidates from URLs without a dist name. This is only possible for
   top-level user requirements, and no recourse is possible for them. So
   we error out eagerly.

The InstallationError raised during distribution preparation is cached
in the factory, like successfully prepared candidates, since we don't
want to repeatedly try to build a candidate if we already know it'd
fail. Plus pip's preparation logic also does not allow packages to be
built multiple times anyway.
2020-12-12 02:23:32 +08:00
Tzu-ping Chung
ffb3d1bc76 Correctly implement yanking logic
Do not return yanked versions from an index, unless the version
range can only be satisfied by yanked candidates.
2020-12-04 23:46:25 +08:00
Tzu-ping Chung
d589795834 Allow constraining an explicit requirement 2020-11-21 22:14:24 +08:00