Repository: pypa/setuptools

Issue:
"Name" metadata keyword not recognized
Starting with v53.1.0 setuptools seems to no longer recognizes the "Name" key in the [metadata] section of setup.cfg. A "name" key is recognized. 

The metadata spec uses "Name". https://packaging.python.org/specifications/core-metadata/.

Possible related to issue #1937 that was merged in at that release. 
"Name" metadata keyword not recognized
Starting with v53.1.0 setuptools seems to no longer recognizes the "Name" key in the [metadata] section of setup.cfg. A "name" key is recognized. 

The metadata spec uses "Name". https://packaging.python.org/specifications/core-metadata/.

Possible related to issue #1937 that was merged in at that release. 


Discussion:
@jaraco If we'd like `metadata` keys to be case-insensitive, I've written a fix to make `metadata` keys all convert to lowercase as it was originally. I'll go ahead and submit PR
> The metadata spec uses "Name". https://packaging.python.org/specifications/core-metadata/.

The metadata spec isn't relevant here. That spec also uses `Description` where Setuptools expects `long_description`.

@melissa-kun-li Thanks for helping here. I advise to restore compatibility, but deprecate the use of keys that are not lowercase (same as how dashes are deprecated).
@jaraco If we'd like `metadata` keys to be case-insensitive, I've written a fix to make `metadata` keys all convert to lowercase as it was originally. I'll go ahead and submit PR
> The metadata spec uses "Name". https://packaging.python.org/specifications/core-metadata/.

The metadata spec isn't relevant here. That spec also uses `Description` where Setuptools expects `long_description`.

@melissa-kun-li Thanks for helping here. I advise to restore compatibility, but deprecate the use of keys that are not lowercase (same as how dashes are deprecated).

Resolving patch:
diff --git a/setuptools/dist.py b/setuptools/dist.py
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -599,6 +599,7 @@ def _parse_config_files(self, filenames=None):  # noqa: C901
 
                     val = parser.get(section, opt)
                     opt = self.dash_to_underscore_warning(opt, section)
+                    opt = self.make_option_lowercase(opt, section)
                     opt_dict[opt] = (filename, val)
 
             # Make the ConfigParser forget everything (so we retain
@@ -636,6 +637,18 @@ def dash_to_underscore_warning(self, opt, section):
                 % (opt, underscore_opt))
         return underscore_opt
 
+    def make_option_lowercase(self, opt, section):
+        if section != 'metadata' or opt.islower():
+            return opt
+
+        lowercase_opt = opt.lower()
+        warnings.warn(
+            "Usage of uppercase key '%s' in '%s' will be deprecated in future "
+            "versions. Please use lowercase '%s' instead"
+            % (opt, section, lowercase_opt)
+        )
+        return lowercase_opt
+
     # FIXME: 'Distribution._set_command_options' is too complex (14)
     def _set_command_options(self, command_obj, option_dict=None):  # noqa: C901
         """


Test patch:
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
--- a/setuptools/tests/test_config.py
+++ b/setuptools/tests/test_config.py
@@ -526,6 +526,25 @@ def test_dash_to_underscore_warning(self, tmpdir):
                 assert metadata.author_email == 'test@test.com'
                 assert metadata.maintainer_email == 'foo@foo.com'
 
+    def test_uppercase_warning(self, tmpdir):
+        # remove this test and the method uppercase_warning() in setuptools.dist
+        # when no longer needed
+        fake_env(
+            tmpdir,
+            '[metadata]\n'
+            'Name = foo\n'
+            'description = Some description\n'
+        )
+        msg = ("Usage of uppercase key 'Name' in 'metadata' will be deprecated in "
+               "future versions. "
+               "Please use lowercase 'name' instead")
+        with pytest.warns(UserWarning, match=msg):
+            with get_dist(tmpdir) as dist:
+                metadata = dist.metadata
+
+        assert metadata.name == 'foo'
+        assert metadata.description == 'Some description'
+
 
 class TestOptions: