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

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

Closed
1 task done
EpicWink opened this issue Jul 1, 2022 · 5 comments · Fixed by #12569
Closed
1 task done

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

EpicWink opened this issue Jul 1, 2022 · 5 comments · Fixed by #12569
Labels
S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature

Comments

@EpicWink
Copy link
Contributor

EpicWink commented Jul 1, 2022

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 EpicWink added S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature labels Jul 1, 2022
@uranusjr
Copy link
Member

uranusjr commented Jul 1, 2022

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.)

@EpicWink
Copy link
Contributor Author

EpicWink commented Jul 1, 2022

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.

@uranusjr
Copy link
Member

uranusjr commented Jul 1, 2022

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.)

@robbiepy
Copy link

robbiepy commented Sep 20, 2022

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?

@uranusjr
Copy link
Member

Pull requests are always welcomed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants