Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 621-style license field shows the entire license text #12392

Closed
GergelyKalmar opened this issue Oct 19, 2022 · 12 comments · Fixed by #12653
Closed

PEP 621-style license field shows the entire license text #12392

GergelyKalmar opened this issue Oct 19, 2022 · 12 comments · Fixed by #12653
Labels

Comments

@GergelyKalmar
Copy link

Describe the bug
When using PEP 621-style project metadata with a license file (see https://peps.python.org/pep-0621/#license), the entire license text is shown in the Meta -> License section of a package on pypi. For an example see https://pypi.org/project/pytest-logikal/ and the relevant pyproject.toml file https://github.com/logikal-io/pytest-logikal/blob/main/pyproject.toml#L10. Showing the entire license text makes the Meta section almost useless by pushing the rest of the metadata quite far to the bottom.

Expected behavior
The license text should be hidden by default and perhaps shown with a modal upon clicking "see full text". Note that the issue is similar to #1354, however, it is a little different due to the PEP 621 standard causing this behavior. With more and more projects adopting PEP 621 I would expect this to be a bigger issue over time.

@GergelyKalmar GergelyKalmar added bug 🐛 requires triaging maintainers need to do initial inspection of issue labels Oct 19, 2022
@di
Copy link
Member

di commented Oct 20, 2022

Some related discussion is here: https://github.com/FFY00/meson-python/issues/129

@di di removed the requires triaging maintainers need to do initial inspection of issue label Oct 20, 2022
@GergelyKalmar
Copy link
Author

GergelyKalmar commented Oct 20, 2022

Thanks for the context! I think that the current UX needs to be improved regardless of how PEP 639 goes, the "Meta" section is really messed up for anyone who follows PEP 621 right now (which is the accepted standard at the moment). I think showing the (short) license name from the trove classifier there is more than enough (when available) with a fallback to the first line of the license text or so. PEP 639 would use different fields anyways, so even if that gets accepted you need to be able to deal with all the "legacy" approaches like PEP 621 or anything from before.

It seems to me that that area in the PyPI UI is not meant for displaying anything more than a short-ish line anyhow, so at the very least the excess text should be truncated/hidden.

@GergelyKalmar
Copy link
Author

I must add that currently setuptools just copies the contents of the referenced license file into the "License" field in PKG-INFO, so it can be interpreted that the contents of the field are the actual license text of the package. I can imagine that displaying the entire license on PyPI would be potentially useful, just not in the way it is done at the moment.

@GergelyKalmar
Copy link
Author

Lastly, I see what you mean by https://packaging.python.org/en/latest/specifications/core-metadata/#license and so I believe setuptools does the right thing, we should probably just not use the license field together with the trove classifiers (in light of the core metadata specification). Nonetheless, even if someone used the license field according to the PyPA specification and added a longer custom license text there, the Meta section on PyPI would be still messed up, so I think this is indeed a valid bug, regardless of the slightly confusing specifications surrounding license information.

@rgommers
Copy link

rgommers commented Nov 5, 2022

Some related discussion is here: https://github.com/FFY00/meson-python/issues/129

The repo moved, here is the new link: mesonbuild/meson-python#129

@FFY00
Copy link
Member

FFY00 commented Dec 8, 2022

The issue isn't fully resolved yet. Reopening.

@FFY00 FFY00 reopened this Dec 8, 2022
@di
Copy link
Member

di commented Dec 8, 2022

What would you like PyPI to do here that isn't already covered by #1354? We unfortunately have no way to distinguish that contents of the License field are due to PEP 621, just that it's a very long string that breaks our UI.

@GergelyKalmar
Copy link
Author

It kinda works for me, even though the current implementation with just the truncation is a bit rough. I guess having a preference to just show the license as parsed from the trove classifier when there's one would be more elegant. Is there anything against doing just that?

@di
Copy link
Member

di commented Dec 15, 2022

Yes. Here's what I wrote in mesonbuild/meson-python#129 (comment):

Because, historically, when someone specifies the License field, they wanted to see that value displayed on PyPI. Per the core metadata spec, License is supposed to be used instead of classifiers:

Text indicating the license covering the distribution where the license is not a selection from the “License” Trove classifiers.

But in practice, people tend to specify both. Generally, providing multiple lines for License is a configuration mistake, so instead of dropping an entire file in the sidebar, PyPI just displays the first line, which is usually the name of the license (but isn't guaranteed to be).

So if you don't want to see the truncated bit, the solution is to not specify it as License and just use the classifiers instead.

@GergelyKalmar
Copy link
Author

I understand, it's just that this approach seems to be very counter-intuitive in light of PEP 621. What you are saying essentially means we must not use the license field as recommended there whenever we use a standard license. That is really confusing.

Perhaps what was proposed in #1354 would indeed be the most elegant solution after all. Having a link saying "see full license text" instead of the current truncated sentence seems like the most user- and package author-friendly approach.

@rgommers
Copy link

I noticed that this is now working much better. I don't know if it was fixed on purpose, and if so, by whom and how. But thank you either way:)

This issue can probably be closed now? Here is what it now looks like for SciPy (pytest-logikal and other packages I checked look good too):

image

@GergelyKalmar
Copy link
Author

I guess the core issue is solved, although the truncation is not a particularly elegant approach. There's other issues tracking better alternatives (e.g. #1354), so I'll close this issue in favor of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants