Skip to content

Optional metadata#3289

Closed
wimglenn wants to merge 4 commits intopypa:mainfrom
wimglenn:optional-metadata
Closed

Optional metadata#3289
wimglenn wants to merge 4 commits intopypa:mainfrom
wimglenn:optional-metadata

Conversation

@wimglenn
Copy link
Copy Markdown
Contributor

Companion to pypa/distutils#138

  • Stop backfilling Project-URL: homepage, https://example.org into Home-page: https://example.org
  • Similar with Download-URL
  • Remove warnings about missing url / author / maintainer etc, these are all optional fields in the spec
  • Prevent adding in extra whitespace to the long description
  • Prevent "UNKNOWN" strings from creeping in when fields weren't specified by user

Related: pypi/warehouse#11220

…uplicates on PyPI). prevent "UNKNOWN" vals from appearing in summary, license, platform. prevent an extra newline getting added in long description
@abravalheri
Copy link
Copy Markdown
Contributor

Thank you very @wimglenn.

Let's see how the discussion in the disutils repository evolves.

@jaraco
Copy link
Copy Markdown
Member

jaraco commented Apr 30, 2022

Is there any way this change could be applied to Setuptools such that _distutils doesn't have to be altered first?

@abravalheri
Copy link
Copy Markdown
Contributor

abravalheri commented Apr 30, 2022

My interpretation is the following:

  1. If distutils is not changed, the user will see some warnings that will not make sense (and even be conceptually unjustified), but the build will ultimately pass. That is a bad UX, so I think it would be better to leave things as they are right now.

  2. The same will happen if distutils changes, but the user sets SETUPTOOLS_USE_DISTUTILS=stblib. Maybe we can see the bad UX in this case as a compromise? The minority of users will run in this compatibility mode...

  3. Not sure about the following, but maybe, it is possible to overwrite the check command in the setuptools layer via entry-point (this approach may involve code duplication).

@abravalheri
Copy link
Copy Markdown
Contributor

(The last 2 bullet points in the description are fine and not part of the problem with the UX...)

@wimglenn
Copy link
Copy Markdown
Contributor Author

wimglenn commented May 2, 2022

@jaraco I double checked everything and I don't think there is any incompatibility. The setuptools change can go in before the distutils change, and we would not be in a worse place - however the 3rd and the 5th bullet points would remain unfixed (because they need the distutils changes). Bullet points 1, 2, and 4 would be fixed by the setuptools change only.

Point 3 is about the warnings from the check command, they look like this:

$ python3 setup.py sdist -v
...
warning: check: missing required meta-data: url
warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) should be supplied
...

The build still succeeds and makes a valid distribution, they're just bogus warnings. To fix this in setuptools directly without changing distutils you'd have to reimplement the check command, which is the source of the warnings, it currently exists in distutils only.

Point 5 is about the "UNKNOWN" strings, these are also coming from distutils. Currently if you omit Summary, License, or Platform you get a PKG-INFO file with lines like this:

Metadata-Version: 2.1
Name: mypkg
Version: 0.1
Summary: UNKNOWN
License: UNKNOWN
Platform: UNKNOWN

That's because the "getters" for these fields aren't patched by setuptools, so it goes to distutils Distribution class for them: get_description, get_license, and get_platforms. To fix that in setuptools directly we could check their return values, or re-implement them on the setuptools Distribution class, but I personally think it's better just to fix the issue where it was caused directly.

So, in summary, there is no incompatibility - I tested with SETUPTOOLS_USE_DISTUTILS=stblib - and the build still works but users would continue to get the bogus warnings and those UNKNOWN fields, so only 3 of the 5 points above actually get solved.

@wimglenn
Copy link
Copy Markdown
Contributor Author

wimglenn commented May 9, 2022

@jaraco ping.. anything more required here?

@jaraco
Copy link
Copy Markdown
Member

jaraco commented May 9, 2022

I'd like to proceed instead with #3299, then confirm tests pass in pypa/distutils#138 and merge that into setuptools.

@jaraco jaraco closed this May 9, 2022
@wimglenn wimglenn deleted the optional-metadata branch May 9, 2022 13:46
ni-balexand referenced this pull request Jun 10, 2022
Optional fields are really optional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants