Repository: pypa/pip
Issue: `pip --use-deprecated legacy-resolver download ...` fails at b88addeaf5fde848733d7ef631caa522eb1cfa53

### Description

I bisected to b88addeaf5fde848733d7ef631caa522eb1cfa53 (#11945) using:
```
PYTHONPATH=src python3.12 -mpip --use-deprecated legacy-resolver download setuptools==68.0.0
```

The error is:
```
$ PYTHONPATH=src python3.12 -mpip --use-deprecated legacy-resolver download setuptools==68.0.0
Collecting setuptools==68.0.0
  Obtaining dependency information for setuptools==68.0.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl.metadata
  Using cached setuptools-68.0.0-py3-none-any.whl.metadata (6.4 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/cli/req_command.py", line 248, in wrapper
    return func(self, options, args)
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/commands/download.py", line 133, in run
    requirement_set.warn_legacy_versions_and_specifiers()
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/req/req_set.py", line 89, in warn_legacy_versions_and_specifiers
    version = req.get_dist().version
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/req/req_install.py", line 598, in get_dist
    raise AssertionError(
AssertionError: InstallRequirement setuptools==68.0.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl has no metadata directory and no wheel: can't make a distribution.
```

### Expected behavior

No backtrace / blowup or else removal of `--use-deprecated` support for `legacy-resolver` as per: https://pip.pypa.io/en/latest/user_guide/#deprecation-timeline

### pip version

unreleased: main @ b88addeaf5fde848733d7ef631caa522eb1cfa53

### Python version

3.12 (but same with others)

### OS

Linux (Ubuntu 22.04)

### How to Reproduce

See above, but in a pypa/pip clone:
```
PYTHONPATH=src python -mpip --use-deprecated legacy-resolver download setuptools==68.0.0
```

### Output

```
$ PYTHONPATH=src python3.12 -mpip --use-deprecated legacy-resolver download setuptools==68.0.0
Collecting setuptools==68.0.0
  Obtaining dependency information for setuptools==68.0.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl.metadata
  Using cached setuptools-68.0.0-py3-none-any.whl.metadata (6.4 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/cli/req_command.py", line 248, in wrapper
    return func(self, options, args)
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/commands/download.py", line 133, in run
    requirement_set.warn_legacy_versions_and_specifiers()
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/req/req_set.py", line 89, in warn_legacy_versions_and_specifiers
    version = req.get_dist().version
  File "/home/jsirois/dev/pypa/pip/src/pip/_internal/req/req_install.py", line 598, in get_dist
    raise AssertionError(
AssertionError: InstallRequirement setuptools==68.0.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl has no metadata directory and no wheel: can't make a distribution.
```

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).

Changed files:
src/pip/_internal/commands/download.py
src/pip/_internal/commands/wheel.py
src/pip/_internal/resolution/resolvelib/resolver.py

diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py
index 63bd53a50..54247a78a 100644
--- a/src/pip/_internal/commands/download.py
+++ b/src/pip/_internal/commands/download.py
@@ -130,7 +130,6 @@ class DownloadCommand(RequirementCommand):
         self.trace_basic_info(finder)
 
         requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
-        requirement_set.warn_legacy_versions_and_specifiers()
 
         downloaded: List[str] = []
         for req in requirement_set.requirements.values():
@@ -138,6 +137,10 @@ class DownloadCommand(RequirementCommand):
                 assert req.name is not None
                 preparer.save_linked_requirement(req)
                 downloaded.append(req.name)
+
+        preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
+        requirement_set.warn_legacy_versions_and_specifiers()
+
         if downloaded:
             write_output("Successfully downloaded %s", " ".join(downloaded))
 
diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py
index e6735bd8d..ed578aa25 100644
--- a/src/pip/_internal/commands/wheel.py
+++ b/src/pip/_internal/commands/wheel.py
@@ -145,7 +145,6 @@ class WheelCommand(RequirementCommand):
         self.trace_basic_info(finder)
 
         requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
-        requirement_set.warn_legacy_versions_and_specifiers()
 
         reqs_to_build: List[InstallRequirement] = []
         for req in requirement_set.requirements.values():
@@ -154,6 +153,9 @@ class WheelCommand(RequirementCommand):
             elif should_build_for_wheel_command(req):
                 reqs_to_build.append(req)
 
+        preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
+        requirement_set.warn_legacy_versions_and_specifiers()
+
         # build wheels
         build_successes, build_failures = build(
             reqs_to_build,
diff --git a/src/pip/_internal/resolution/resolvelib/resolver.py b/src/pip/_internal/resolution/resolvelib/resolver.py
index 47bbfecce..d5b238608 100644
--- a/src/pip/_internal/resolution/resolvelib/resolver.py
+++ b/src/pip/_internal/resolution/resolvelib/resolver.py
@@ -159,6 +159,9 @@ class Resolver(BaseResolver):
 
         reqs = req_set.all_requirements
         self.factory.preparer.prepare_linked_requirements_more(reqs)
+        for req in reqs:
+            req.prepared = True
+            req.needs_more_preparation = False
         return req_set
 
     def get_installation_order(