Skip to content

Commit e43e167

Browse files
make it work without --use-feature=fast-deps!
1 parent 3c508cb commit e43e167

File tree

2 files changed

+24
-35
lines changed

2 files changed

+24
-35
lines changed

src/pip/_internal/operations/prepare.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,15 @@ def _fetch_metadata_only(
333333
self,
334334
req: InstallRequirement,
335335
) -> Optional[BaseDistribution]:
336-
# --use-feature=fast-deps must be provided.
337-
if not self.use_lazy_wheel:
338-
return None
339336
if self.require_hashes:
340337
logger.debug(
341338
"Metadata-only fetching is not used as hash checking is required",
342339
)
343340
return None
344341
# Try PEP 658 metadata first, then fall back to lazy wheel if unavailable.
345-
pep_658_dist = self._fetch_metadata_using_pep_658(req)
346-
if pep_658_dist is not None:
347-
return pep_658_dist
348-
return self._fetch_metadata_using_lazy_wheel(req.link)
342+
return self._fetch_metadata_using_pep_658(
343+
req
344+
) or self._fetch_metadata_using_lazy_wheel(req.link)
349345

350346
def _fetch_metadata_using_pep_658(
351347
self,
@@ -355,6 +351,12 @@ def _fetch_metadata_using_pep_658(
355351
metadata_link = req.link.metadata_link()
356352
if metadata_link is None:
357353
return None
354+
assert req.req is not None
355+
logger.info(
356+
"Obtaining dependency information for %s from %s",
357+
req.req,
358+
metadata_link,
359+
)
358360
metadata_file = get_http_url(
359361
metadata_link,
360362
self._download,
@@ -366,7 +368,6 @@ def _fetch_metadata_using_pep_658(
366368
containing_dir = os.path.dirname(metadata_file.path)
367369
new_metadata_path = os.path.join(containing_dir, "METADATA")
368370
os.rename(metadata_file.path, new_metadata_path)
369-
assert req.req is not None
370371
return get_metadata_distribution(
371372
new_metadata_path,
372373
req.link.filename,
@@ -378,9 +379,12 @@ def _fetch_metadata_using_lazy_wheel(
378379
link: Link,
379380
) -> Optional[BaseDistribution]:
380381
"""Fetch metadata using lazy wheel, if possible."""
382+
# --use-feature=fast-deps must be provided.
383+
if not self.use_lazy_wheel:
384+
return None
381385
if link.is_file or not link.is_wheel:
382386
logger.debug(
383-
"Lazy wheel is not used as %r does not points to a remote wheel",
387+
"Lazy wheel is not used as %r does not point to a remote wheel",
384388
link,
385389
)
386390
return None

tests/functional/test_download.py

+11-26
Original file line numberDiff line numberDiff line change
@@ -1350,34 +1350,22 @@ def download_generated_index(
13501350
def run_for_generated_index(
13511351
packages: Dict[str, List[Package]],
13521352
args: List[str],
1353-
fast_deps: bool = False,
13541353
allow_error: bool = False,
13551354
) -> Tuple[TestPipResult, Path]:
13561355
"""
13571356
Produce a PyPI directory structure pointing to the specified packages, then
13581357
execute `pip download -i ...` pointing to our generated index.
13591358
"""
13601359
index_dir = index_for_packages(packages)
1361-
pip_args = []
1362-
if fast_deps:
1363-
pip_args.append("--use-feature=fast-deps")
1364-
pip_args.extend(
1365-
[
1366-
"download",
1367-
"-d",
1368-
str(download_dir),
1369-
"-i",
1370-
path_to_url(index_dir),
1371-
]
1372-
)
1373-
pip_args.extend(args)
1374-
result = script.pip(
1375-
*pip_args,
1376-
# We need allow_stderr_warning=True if fast_deps=True, since that will print
1377-
# a warning to stderr.
1378-
allow_stderr_warning=fast_deps,
1379-
allow_error=allow_error,
1380-
)
1360+
pip_args = [
1361+
"download",
1362+
"-d",
1363+
str(download_dir),
1364+
"-i",
1365+
path_to_url(index_dir),
1366+
*args,
1367+
]
1368+
result = script.pip(*pip_args, allow_error=allow_error)
13811369
return (result, download_dir)
13821370

13831371
return run_for_generated_index
@@ -1413,12 +1401,11 @@ def test_download_metadata(
14131401
requirement_to_download: str,
14141402
expected_outputs: List[str],
14151403
) -> None:
1416-
"""Verify that when using --use-feature=fast-deps, if a data-dist-info-metadata
1417-
attribute is present, then it is used instead of the actual dist's METADATA."""
1404+
"""Verify that if a data-dist-info-metadata attribute is present, then it is used
1405+
instead of the actual dist's METADATA."""
14181406
_, download_dir = download_generated_index(
14191407
_simple_packages,
14201408
[requirement_to_download],
1421-
fast_deps=True,
14221409
)
14231410
assert sorted(os.listdir(download_dir)) == expected_outputs
14241411

@@ -1442,7 +1429,6 @@ def test_incorrect_metadata_hash(
14421429
result, _ = download_generated_index(
14431430
_simple_packages,
14441431
[requirement_to_download],
1445-
fast_deps=True,
14461432
allow_error=True,
14471433
)
14481434
assert result.returncode != 0
@@ -1466,7 +1452,6 @@ def test_metadata_not_found(
14661452
result, _ = download_generated_index(
14671453
_simple_packages,
14681454
[requirement_to_download],
1469-
fast_deps=True,
14701455
allow_error=True,
14711456
)
14721457
assert result.returncode != 0

0 commit comments

Comments
 (0)