aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-12-18 09:03:51 -0500
committerJason R. Coombs <jaraco@jaraco.com>2014-12-18 09:03:51 -0500
commitfba52114f45e36b677ef9c200a8475397317412a (patch)
tree131bf46f86c8a64a7292e66159de3a4a62b6cd0a /pkg_resources.py
parent98541aa903a618020b22b25b6ee3a53b4dba0c9c (diff)
parent123ac3c8a389d3b9168abbb901c6507282b27dc2 (diff)
downloadexternal_python_setuptools-fba52114f45e36b677ef9c200a8475397317412a.tar.gz
external_python_setuptools-fba52114f45e36b677ef9c200a8475397317412a.tar.bz2
external_python_setuptools-fba52114f45e36b677ef9c200a8475397317412a.zip
Merge with 8.18.2
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 5af4c869..87fd2782 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -80,6 +80,13 @@ import setuptools._vendor.packaging.specifiers
packaging = setuptools._vendor.packaging
+class PEP440Warning(RuntimeWarning):
+ """
+ Used when there is an issue with a version or specifier not complying with
+ PEP 440.
+ """
+
+
class _SetuptoolsVersionMixin(object):
def __hash__(self):
@@ -272,6 +279,9 @@ __all__ = [
'ResolutionError', 'VersionConflict', 'DistributionNotFound',
'UnknownExtra', 'ExtractionError',
+ # Warnings
+ 'PEP440Warning',
+
# Parsing functions and string utilities
'parse_requirements', 'parse_version', 'safe_name', 'safe_version',
'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections',
@@ -2415,15 +2425,23 @@ class Distribution(object):
self._parsed_version = parse_version(self.version)
if isinstance(
self._parsed_version, packaging.version.LegacyVersion):
- warnings.warn(
- "'%s (%s)' is being parsed as a legacy, non PEP 440, "
- "version. You may find odd behavior and sort order. In "
- "particular it will be sorted as less than 0.0. It is "
- "recommend to migrate to PEP 440 compatible versions." % (
- self.project_name, self.version,
- ),
- RuntimeWarning,
- )
+ # While an empty version is techincally a legacy version and
+ # is not a valid PEP 440 version, it's also unlikely to
+ # actually come from someone and instead it is more likely that
+ # it comes from setuptools attempting to parse a filename and
+ # including it in the list. So for that we'll gate this warning
+ # on if the version is anything at all or not.
+ if self.version:
+ warnings.warn(
+ "'%s (%s)' is being parsed as a legacy, non PEP 440, "
+ "version. You may find odd behavior and sort order. "
+ "In particular it will be sorted as less than 0.0. It "
+ "is recommend to migrate to PEP 440 compatible "
+ "versions." % (
+ self.project_name, self.version,
+ ),
+ PEP440Warning,
+ )
return self._parsed_version