| 
7 | 7 | import inspect  | 
8 | 8 | import os  | 
9 | 9 | import pathlib  | 
10 |  | -import shutil  | 
11 | 10 | import stat  | 
12 | 11 | import subprocess  | 
13 | 12 | import sys  | 
 | 
18 | 17 | import pytest  | 
19 | 18 | from jaraco import path  | 
20 | 19 | from packaging.tags import parse_tag  | 
21 |  | -from packaging.utils import canonicalize_name  | 
22 | 20 | 
 
  | 
23 |  | -from pkg_resources import Distribution, PathMetadata  | 
 | 21 | +from setuptools._importlib import metadata  | 
24 | 22 | from setuptools.wheel import Wheel  | 
25 | 23 | 
 
  | 
26 | 24 | from .contexts import tempdir  | 
@@ -160,15 +158,13 @@ def _check_wheel_install(  | 
160 | 158 |  exp = tree_set(install_dir)  | 
161 | 159 |  assert install_tree.issubset(exp), install_tree - exp  | 
162 | 160 | 
 
  | 
163 |  | - metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO'))  | 
164 |  | - dist = Distribution.from_filename(egg_path, metadata=metadata)  | 
165 |  | - assert dist.project_name == project_name  | 
166 |  | - assert dist.version == version  | 
167 |  | - if requires_txt is None:  | 
168 |  | - assert not dist.has_metadata('requires.txt')  | 
169 |  | - else:  | 
170 |  | - # Order must match to ensure reproducibility.  | 
171 |  | - assert requires_txt == dist.get_metadata('requires.txt').lstrip()  | 
 | 161 | + (dist,) = metadata.Distribution.discover(path=[egg_path])  | 
 | 162 | + | 
 | 163 | + # pyright is nitpicky; fine to assume dist.metadata.__getitem__ will fail or return None  | 
 | 164 | + # (https://github.com/pypa/setuptools/pull/5006#issuecomment-2894774288)  | 
 | 165 | + assert dist.metadata['Name'] == project_name # pyright: ignore # noqa: PGH003  | 
 | 166 | + assert dist.metadata['Version'] == version # pyright: ignore # noqa: PGH003  | 
 | 167 | + assert dist.read_text('requires.txt') == requires_txt  | 
172 | 168 | 
 
  | 
173 | 169 | 
 
  | 
174 | 170 | class Record:  | 
@@ -407,7 +403,8 @@ def __repr__(self) -> str:  | 
407 | 403 |  extras_require={  | 
408 | 404 |  'extra': f'foobar; {sys.platform!r} != sys_platform',  | 
409 | 405 |  },  | 
410 |  | - requires_txt=DALS(  | 
 | 406 | + requires_txt='\n'  | 
 | 407 | + + DALS(  | 
411 | 408 |  """  | 
412 | 409 |  [extra]  | 
413 | 410 |  """  | 
@@ -579,28 +576,6 @@ def test_wheel_install(params):  | 
579 | 576 |  )  | 
580 | 577 | 
 
  | 
581 | 578 | 
 
  | 
582 |  | -def test_wheel_install_pep_503():  | 
583 |  | - project_name = 'Foo_Bar' # PEP 503 canonicalized name is "foo-bar"  | 
584 |  | - version = '1.0'  | 
585 |  | - with (  | 
586 |  | - build_wheel(  | 
587 |  | - name=project_name,  | 
588 |  | - version=version,  | 
589 |  | - ) as filename,  | 
590 |  | - tempdir() as install_dir,  | 
591 |  | - ):  | 
592 |  | - new_filename = filename.replace(project_name, canonicalize_name(project_name))  | 
593 |  | - shutil.move(filename, new_filename)  | 
594 |  | - _check_wheel_install(  | 
595 |  | - new_filename,  | 
596 |  | - install_dir,  | 
597 |  | - None,  | 
598 |  | - canonicalize_name(project_name),  | 
599 |  | - version,  | 
600 |  | - None,  | 
601 |  | - )  | 
602 |  | - | 
603 |  | - | 
604 | 579 | def test_wheel_no_dist_dir():  | 
605 | 580 |  project_name = 'nodistinfo'  | 
606 | 581 |  version = '1.0'  | 
 | 
0 commit comments