This is a much better location for these errors, since they're in a much
more visible spot. We've had reports in the past of users missing these
messages, and changing where we present these warnings should help
resolve that issue.
We do lose the ability for an advanced user to potentially see the
warning and abort installation before the conflicts are introduced, but
given that we don't even pause for input, I don't think that's a strong
argument and neither do I view this as necessary.
The duplication of this code isn't really that bad, but saying
"pip check" makes it ambigous which file is relevant. Changing to
reference the exact filename makes this clearer.
The RequirementSet implementation conflates requirements incorrectly in
a lot of places. This means the (new) resolver would get incomplete
requirements.
The removes all RequirementSet.add_requirement() calls outside of the
legacy resolver, so the new resolver can get the unmodified list of
requirements specified by the user, allowing for more sophisticated
requirement merging.
The lifetime of the requirement tracker will be essentially the same,
but now we have more flexibility on where in the code we create it.
In a followup we can do the same thing with build_dir and remove the
`with` statement (and its indentation) entirely from these commands.
Since a recent refactoring of our temporary directory handling,
`no_clean` is only read prior to these `except` blocks. Since it's not
needed, remove it!
This makes the resolver interface simpler by returning a brand new
RequirementSet vs mutating the one that was input to the function, and
will let us specialize RequirementSet for the different use cases.
This mirrors the current logic within the individual requirement-related
commands (install, wheel) for setting options.no_clean, which is used to
determine whether we need to delete directories.
Next, we'll add the actual directories to track and remove them from
being managed by other objects.
_should_cache is only called by _get_cache_dir.
In pip install mode, _get_cache_dir is never called when
check_binary_allowed returns False because in that case
should_build_for_install_command has returned False before
and the build was skipped.
In pip wheel mode, check_binary_allowed always returns True
(because it is not passed to the build function).
So _should_cache can use _always_true for check_binary_allowed.
*Alternative*
Alternatively, we could have passed check_binary_allowed
to build in pip wheel mode. The only difference is that wheels built
locally from *legacy* packages would then not be cached,
when pip wheel is used with --no-binary.