Skip to content

Commit 4fadb95

Browse files
committed
Make deprecation warning more visible and mention --use-pep517
1 parent 30c8c9b commit 4fadb95

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ filterwarnings=
4040
ignore:The Windows bytes API has been deprecated:DeprecationWarning
4141

4242
# https://github.com/pypa/setuptools/issues/2823
43-
ignore:setuptools.installer is deprecated.
43+
ignore:(.|\s)*setuptools.installer. is deprecated(.|\s)*
4444

4545
# https://github.com/pypa/setuptools/issues/917
4646
ignore:setup.py install is deprecated.

setuptools/installer.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ def fetch_build_egg(dist, req): # noqa: C901 # is too complex (16) # FIXME
2424
"""Fetch an egg needed for building.
2525
2626
Use pip/wheel to fetch/build a wheel."""
27-
warnings.warn(
28-
"setuptools.installer is deprecated. Requirements should "
29-
"be satisfied by a PEP 517 installer.",
30-
SetuptoolsDeprecationWarning,
31-
)
27+
_DeprecatedWorkflow.warn(req, stacklevel=2)
3228
# Warn if wheel is not available
3329
try:
3430
pkg_resources.get_distribution('wheel')
@@ -102,3 +98,22 @@ def strip_marker(req):
10298
req = pkg_resources.Requirement.parse(str(req))
10399
req.marker = None
104100
return req
101+
102+
103+
class _DeprecatedWorkflow(SetuptoolsDeprecationWarning):
104+
"""Deprecated installation or configuration method for requirement: {req}
105+
!!\n\n
106+
########################
107+
# Deprecated Workflow #
108+
########################
109+
`setuptools.installer` is deprecated. Requirements should
110+
be satisfied by a PEP 517 installer.
111+
112+
If you are using `pip install` you can try adding the `--use-pep517` flag.
113+
\n\n!!
114+
"""
115+
116+
@classmethod
117+
def warn(cls, req, stacklevel=1):
118+
msg = cls.__doc__.format(req=req)
119+
warnings.warn(msg, cls, stacklevel=stacklevel+1)

0 commit comments

Comments
 (0)