Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3085.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed reliance on pkg_resources in test_wheel.
45 changes: 10 additions & 35 deletions setuptools/tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import inspect
import os
import pathlib
import shutil
import stat
import subprocess
import sys
Expand All @@ -18,9 +17,8 @@
import pytest
from jaraco import path
from packaging.tags import parse_tag
from packaging.utils import canonicalize_name

from pkg_resources import Distribution, PathMetadata
from setuptools._importlib import metadata
from setuptools.wheel import Wheel

from .contexts import tempdir
Expand Down Expand Up @@ -160,15 +158,13 @@ def _check_wheel_install(
exp = tree_set(install_dir)
assert install_tree.issubset(exp), install_tree - exp

metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO'))
dist = Distribution.from_filename(egg_path, metadata=metadata)
assert dist.project_name == project_name
assert dist.version == version
if requires_txt is None:
assert not dist.has_metadata('requires.txt')
else:
# Order must match to ensure reproducibility.
assert requires_txt == dist.get_metadata('requires.txt').lstrip()
(dist,) = metadata.Distribution.discover(path=[egg_path])

# pyright is nitpicky; fine to assume dist.metadata.__getitem__ will fail or return None
# (https://github.com/pypa/setuptools/pull/5006#issuecomment-2894774288)
assert dist.metadata['Name'] == project_name # pyright: ignore # noqa: PGH003
assert dist.metadata['Version'] == version # pyright: ignore # noqa: PGH003
assert dist.read_text('requires.txt') == requires_txt


class Record:
Expand Down Expand Up @@ -407,7 +403,8 @@ def __repr__(self) -> str:
extras_require={
'extra': f'foobar; {sys.platform!r} != sys_platform',
},
requires_txt=DALS(
requires_txt='\n'
+ DALS(
"""
[extra]
"""
Expand Down Expand Up @@ -579,28 +576,6 @@ def test_wheel_install(params):
)


def test_wheel_install_pep_503():
project_name = 'Foo_Bar' # PEP 503 canonicalized name is "foo-bar"
version = '1.0'
with (
build_wheel(
name=project_name,
version=version,
) as filename,
tempdir() as install_dir,
):
new_filename = filename.replace(project_name, canonicalize_name(project_name))
shutil.move(filename, new_filename)
_check_wheel_install(
new_filename,
install_dir,
None,
canonicalize_name(project_name),
version,
None,
)


def test_wheel_no_dist_dir():
project_name = 'nodistinfo'
version = '1.0'
Expand Down
Loading