pip icon indicating copy to clipboard operation
pip copied to clipboard

Show 'home-page' project URL when Home-Page metadata value is not set

Open EpicWink opened this issue 2 years ago • 4 comments

What's the problem this feature will solve?

When installing a pyproject.toml-only project, the Home-Page metadata won't be set (as there's no way to specify it: PEP 621 only maps to Project-Url). This means pip show won't provide any URL to the user.

Describe the solution you'd like

If Home-Page is not set, instead select one of the project URLs (if present), with the following order of preference:

  • Home-page
  • Homepage
  • homepage
  • Source
  • fallback: the first project-URL in the metadata

Alternative Solutions

pip show -v shows all project URLs, but that still shows an empty Home-page: field

Additional context

Project URLs were included in pip show -v in #10827

Code of Conduct

EpicWink avatar Jul 01 '22 06:07 EpicWink

Perhaps it is better to match PyPI’s display. This is how warehouse does it:

https://github.com/pypi/warehouse/blob/39daea188d2e1e6494c50753cd48cb5a8da3e8c4/warehouse/packaging/models.py#L537-L558

(self.home_page comes from Home-page, self.download_url is from the legacy Download-URL.)

uranusjr avatar Jul 01 '22 07:07 uranusjr

Do you want to see all project URLs (without passing -v (--verbose))? I think it's best to see exactly one (if any are available) (unless -v is passed).

I like Warehouse's logic otherwise.

EpicWink avatar Jul 01 '22 07:07 EpicWink

There’s already discussion on that #11138. It’s probably best to show one by default, and more in verbose mode. (I wouldn’t include Source and the fallback in the heuristic though; if there’s nothing that looks like a homepage, I prefer to just show an empty value or something like <unknown> instead.)

uranusjr avatar Jul 01 '22 07:07 uranusjr

Hi, I've come across this issue writing a package with pyproject.toml only. Is there any progress on this issue?

Given pep 621, this issue is going to increasingly get attention. I initially thought I had written pyproject.toml incorrectly, so this issue may confuse some other developers if not resolved.

This is my suggestion: pip show --verbose now works well, showing both Home-page and Project-URLs

pip show (non-verbose) should show either but not both:

a. Home-page if it exists, in usual place:

Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers

at end:

Required-by:

b. or (if Home-page doesn't exist):

Summary: The PyPA recommended tool for installing Python packages.
Author: The pip developers

with one of Project-URLs [Homepage, Documentation, Source] on one line at end, e.g.

Required-by:
Project-URLs: Homepage, https://pip.pypa.io/

c. or Home-page empty, otherwise

Summary: A python package blah blah
Home-page:
Author: The package developers
Required-by:

What this does is maintain pip show for all the pre-existing packages using setup.py, setup.cfg. If there is both Home-page and Project-URLs, Home-page would probably be considered default for the time being. If Home-page doesn't exist, then the developers are either writing to pep 621 or feel the term "homepage" is ambiguous. In which case, pip show still shows one url, but clearly to a different metadata variable.

I don't think there is an ideal solution. This means pip show will be inconsistent, sometimes showing Home-page, other times showing Project-URLs: homepage but it will be informative and, if a url exists, give a url, regardless of where the metadata is written.

I'm happy to write the changes and make a pull request if you agree?

robbiepy avatar Sep 20 '22 11:09 robbiepy

Pull requests are always welcomed.

uranusjr avatar Sep 26 '22 06:09 uranusjr