summaryrefslogtreecommitdiff
path: root/setuptools/_distutils/command/check.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-05-09 10:42:04 -0400
committerJason R. Coombs <jaraco@jaraco.com>2022-05-09 10:42:56 -0400
commit9116c7eb52504bec77d26881d2c28e427dc52143 (patch)
tree6becb88401eb15bdff6fc924211894e6d9c277d1 /setuptools/_distutils/command/check.py
parent8d12d6196c369c7cf0164a1202e968dd68a2cb6c (diff)
parente009a87b5578cb16099b697ba8395c8f6bdd70f3 (diff)
downloadpython-setuptools-git-debt/remove-easy-install.tar.gz
Merge branch 'main' into debt/remove-easy-installdebt/remove-easy-install
Diffstat (limited to 'setuptools/_distutils/command/check.py')
-rw-r--r--setuptools/_distutils/command/check.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/setuptools/_distutils/command/check.py b/setuptools/_distutils/command/check.py
index ada25006..af311ca9 100644
--- a/setuptools/_distutils/command/check.py
+++ b/setuptools/_distutils/command/check.py
@@ -2,6 +2,8 @@
Implements the Distutils 'check' command.
"""
+from email.utils import getaddresses
+
from distutils.core import Command
from distutils.errors import DistutilsSetupError
@@ -17,7 +19,7 @@ try:
def __init__(self, source, report_level, halt_level, stream=None,
debug=0, encoding='ascii', error_handler='replace'):
self.messages = []
- Reporter.__init__(self, source, report_level, halt_level, stream,
+ super().__init__(source, report_level, halt_level, stream,
debug, encoding, error_handler)
def system_message(self, level, message, *children, **kwargs):
@@ -96,19 +98,39 @@ class check(Command):
if missing:
self.warn("missing required meta-data: %s" % ', '.join(missing))
- if metadata.author:
- if not metadata.author_email:
- self.warn("missing meta-data: if 'author' supplied, " +
- "'author_email' should be supplied too")
- elif metadata.maintainer:
- if not metadata.maintainer_email:
- self.warn("missing meta-data: if 'maintainer' supplied, " +
- "'maintainer_email' should be supplied too")
- else:
+ if not (
+ self._check_contact("author", metadata) or
+ self._check_contact("maintainer", metadata)
+ ):
self.warn("missing meta-data: either (author and author_email) " +
"or (maintainer and maintainer_email) " +
"should be supplied")
+ def _check_contact(self, kind, metadata):
+ """
+ Returns True if the contact's name is specified and False otherwise.
+ This function will warn if the contact's email is not specified.
+ """
+ name = getattr(metadata, kind) or ''
+ email = getattr(metadata, kind + '_email') or ''
+
+ msg = ("missing meta-data: if '{}' supplied, " +
+ "'{}' should be supplied too")
+
+ if name and email:
+ return True
+
+ if name:
+ self.warn(msg.format(kind, kind + '_email'))
+ return True
+
+ addresses = [(alias, addr) for alias, addr in getaddresses([email])]
+ if any(alias and addr for alias, addr in addresses):
+ # The contact's name can be encoded in the email: `Name <email>`
+ return True
+
+ return False
+
def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
data = self.distribution.get_long_description()