aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/dist.py
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2014-09-04 21:04:06 -0400
committerDonald Stufft <donald@stufft.io>2014-09-25 20:55:27 -0400
commit9382fa0c05e533400613e1c7c0a777cabb463390 (patch)
tree7cd6f6aebf57ea3b4760cc359b4d4c266a0e04f0 /setuptools/dist.py
parent84c9006110e53c84296a05741edb7b9edd305f12 (diff)
downloadexternal_python_setuptools-9382fa0c05e533400613e1c7c0a777cabb463390.tar.gz
external_python_setuptools-9382fa0c05e533400613e1c7c0a777cabb463390.tar.bz2
external_python_setuptools-9382fa0c05e533400613e1c7c0a777cabb463390.zip
Implement PEP 440 by using the packaging library
Diffstat (limited to 'setuptools/dist.py')
-rw-r--r--setuptools/dist.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py
index 8b36f67c..ae4ff554 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -15,6 +15,7 @@ from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
from setuptools.depends import Require
from setuptools.compat import basestring, PY2
+from setuptools._vendor.packaging.version import Version, InvalidVersion
import pkg_resources
def _get_unpatched(cls):
@@ -268,6 +269,26 @@ class Distribution(_Distribution):
# Some people apparently take "version number" too literally :)
self.metadata.version = str(self.metadata.version)
+ if self.metadata.version is not None:
+ try:
+ normalized_version = str(Version(self.metadata.version))
+ if self.metadata.version != normalized_version:
+ warnings.warn(
+ "The version specified requires normalization, "
+ "consider using '%s' instead of '%s'." % (
+ normalized_version,
+ self.metadata.version,
+ )
+ )
+ self.metadata.version = normalized_version
+ except (InvalidVersion, TypeError):
+ warnings.warn(
+ "The version specified (%r) is an invalid version, this "
+ "may not work as expected with newer versions of "
+ "setuptools, pip, and PyPI. Please see PEP 440 for more "
+ "details." % self.metadata.version
+ )
+
def parse_command_line(self):
"""Process features after parsing command line options"""
result = _Distribution.parse_command_line(self)