@@ -231,18 +231,6 @@ def check_packages(dist, attr, value):
231
231
)
232
232
233
233
234
- def _check_deprecated_metadata_field (
235
- dist : Distribution , attr : str , value : object
236
- ) -> None :
237
- if value :
238
- SetuptoolsDeprecationWarning .emit (
239
- f"Deprecated usage of `{ attr } ` in setuptools configuration." ,
240
- see_docs = f"references/keywords.html#keyword-{ attr .replace ('_' , '-' )} " ,
241
- due_date = (2027 , 1 , 25 ),
242
- # Warning initially introduced in 14 Jan 2025
243
- )
244
-
245
-
246
234
if TYPE_CHECKING :
247
235
# Work around a mypy issue where type[T] can't be used as a base: https://github.com/python/mypy/issues/10962
248
236
from distutils .core import Distribution as _Distribution
@@ -338,9 +326,6 @@ def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None:
338
326
dist_attrs = {k : v for k , v in attrs .items () if k not in metadata_only }
339
327
_Distribution .__init__ (self , dist_attrs )
340
328
341
- for attr in self ._DEPRECATED_FIELDS :
342
- _check_deprecated_metadata_field (self , attr , dist_attrs .get (attr ))
343
-
344
329
# Private API (setuptools-use only, not restricted to Distribution)
345
330
# Stores files that are referenced by the configuration and need to be in the
346
331
# sdist (e.g. `version = file: VERSION.txt`)
@@ -349,9 +334,9 @@ def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None:
349
334
self .set_defaults = ConfigDiscovery (self )
350
335
351
336
self ._set_metadata_defaults (attrs )
352
-
353
337
self .metadata .version = self ._normalize_version (self .metadata .version )
354
338
self ._finalize_requires ()
339
+ self ._check_deprecated_metadata_fields ()
355
340
356
341
def _validate_metadata (self ):
357
342
required = {"name" }
@@ -366,6 +351,16 @@ def _validate_metadata(self):
366
351
msg = f"Required package metadata is missing: { missing } "
367
352
raise DistutilsSetupError (msg )
368
353
354
+ def _check_deprecated_metadata_fields (self ) -> None :
355
+ for attr in self ._DEPRECATED_FIELDS :
356
+ if getattr (self .metadata , attr , None ):
357
+ anchor = f"keyword-{ attr .replace ('_' , '-' )} "
358
+ SetuptoolsDeprecationWarning .emit (
359
+ f"Deprecated usage of `{ attr } ` in setuptools configuration." ,
360
+ see_docs = f"references/keywords.html#{ anchor } " ,
361
+ due_date = (2027 , 1 , 25 ), # introduced in 20 Jan 2025
362
+ )
363
+
369
364
def _set_metadata_defaults (self , attrs ):
370
365
"""
371
366
Fill-in missing metadata fields not supported by distutils.
@@ -1016,8 +1011,9 @@ def handle_display_options(self, option_order):
1016
1011
1017
1012
def run_command (self , command ) -> None :
1018
1013
self .set_defaults ()
1019
- # Postpone defaults until all explicit configuration is considered
1020
- # (setup() args, config files, command line and plugins)
1014
+ self ._check_deprecated_metadata_fields ()
1015
+ # Postpone defaults and validations until all explicit configuration is
1016
+ # considered (setup() args, config files, command line and plugins)
1021
1017
1022
1018
super ().run_command (command )
1023
1019
0 commit comments