diff --git a/setuptools/dist.py b/setuptools/dist.py index 2672f928d52..fce534d4e28 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -26,7 +26,7 @@ from .extern.ordered_set import OrderedSet from .extern.packaging.markers import InvalidMarker, Marker from .extern.packaging.specifiers import InvalidSpecifier, SpecifierSet -from .extern.packaging.version import InvalidVersion, Version +from .extern.packaging.version import Version from . import _entry_points from . import _normalization @@ -311,9 +311,7 @@ def __init__(self, attrs=None): self._set_metadata_defaults(attrs) - self.metadata.version = self._normalize_version( - self._validate_version(self.metadata.version) - ) + self.metadata.version = self._normalize_version(self.metadata.version) self._finalize_requires() def _validate_metadata(self): @@ -343,7 +341,10 @@ def _set_metadata_defaults(self, attrs): def _normalize_version(version): from . import sic - if isinstance(version, sic) or version is None: + if isinstance(version, numbers.Number): + # Some people apparently take "version number" too literally :) + version = str(version) + elif isinstance(version, sic) or version is None: return version normalized = str(Version(version)) @@ -352,33 +353,6 @@ def _normalize_version(version): return normalized return version - @staticmethod - def _validate_version(version): - if isinstance(version, numbers.Number): - # Some people apparently take "version number" too literally :) - version = str(version) - - if version is not None: - try: - Version(version) - except (InvalidVersion, TypeError): - from . import sic - - SetuptoolsDeprecationWarning.emit( - f"Invalid version: {version!r}.", - """ - The version specified is not a valid version according to PEP 440. - This may not work as expected with newer versions of - setuptools, pip, and PyPI. - """, - see_url="https://peps.python.org/pep-0440/", - due_date=(2023, 9, 26), - # Warning initially introduced in 26 Sept 2014 - # pypa/packaging already removed legacy versions. - ) - return sic(version) - return version - def _finalize_requires(self): """ Set `metadata.python_requires` and fix environment markers @@ -550,7 +524,7 @@ def warn_dash_deprecation(self, opt, section): versions. Please use the underscore name {underscore_opt!r} instead. """, see_docs="userguide/declarative_config.html", - due_date=(2023, 9, 26), + due_date=(2024, 9, 26), # Warning initially introduced in 3 Mar 2021 ) return underscore_opt @@ -574,7 +548,7 @@ def make_option_lowercase(self, opt, section): future versions. Please use lowercase {lowercase_opt!r} instead. """, see_docs="userguide/declarative_config.html", - due_date=(2023, 9, 26), + due_date=(2024, 9, 26), # Warning initially introduced in 6 Mar 2021 ) return lowercase_opt