wasi-master / pypi-command-line

A powerful, colorful, beautiful command-line-interface for pypi.org
https://wasi-master.github.io/pypi-command-line/
MIT License
46 stars 7 forks source link

[BUG] GitHub info pane does not always show correct GitHub info if project README contains links to other GitHub repos #8

Closed RhetTbull closed 2 years ago

RhetTbull commented 2 years ago

First, just wanted to say thank for the very useful utility! It's especially impressive given your age. Well done!

Describe the bug The GitHub info pane produced by pypi info does not always show the correct info as the script is grabbing the wrong GitHub link from project README.

To Reproduce Steps to reproduce the behavior:

  1. Use the command pypi info osxphotos
  2. See
    ╭───────── GitHub ─────────╮
    │ Name: pipxproject/pipx   │
    │ Size: 2,993 KB           │
    │ Stargazers: 4,191        │
    │ Issues/Pull Requests: 89 │
    │ Forks: 199               │
    ╰──────────────────────────╯

    Which is the GitHub info for pipx not osxphotos.

Also, try pypi info osxmetadata which shows this for the GitHub info:

╭───────── GitHub ──────────╮
│ Name: python/black        │
│ Size: 5,863 KB            │
│ Stargazers: 23,296        │
│ Issues/Pull Requests: 347 │
│ Forks: 1,477              │
╰───────────────────────────╯

Expected behavior Expected to see the GitHub info for the project instead of a different project. This info is correctly shown by pypi.org.

Screenshots pypi info osxphotos

Screen Shot 2021-10-22 at 6 47 08 AM

Same info from pypi.org

Screen Shot 2021-10-22 at 6 46 36 AM

pypi info osxmetadata

Screen Shot 2021-10-22 at 6 45 43 AM

Same info from pypi.org

Screen Shot 2021-10-22 at 6 46 10 AM

Desktop (please complete the following information):

Additional context I believe the problem occurs when the project README contains a link to a GitHub repo that is not the repo for the project. This is quite common. For example, in the examples above, the project README contains a badge for code style black: [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)

And also instructions to use pipx for installation and these GitHub repos are getting grabbed as the source repo for the package in these lines:

https://github.com/wasi-master/pypi-command-line/blob/a65095fadc4fc2dcbec9e30589ff262fef9dc075/pypi_cli/__main__.py#L920-L924

pypi.org does correctly parse the GitHub info so perhaps you can grab the data there or parse it the same they do. Both the projects in question, do contain a GitHub link in their project setup.py:

https://github.com/RhetTbull/osxphotos/blob/0e9b9d625190b94c1dd68276e3b0e5367002d87c/setup.py#L60

wasi-master commented 2 years ago

Thanks for the detailed issue.

I believe I added some logic if there are multiple github repos for the other commands like description. I forgot to do that in the information command.

Yeah I should get it from pypi directly, I used to do that before I don't really remember why I removed that. I'll start working on it

Edit: I believe I did that because the project urls field of setuptools accepts a lot of items as keys, so the key of the dictionary could be named Source Code or Github or it may not even have a source code/github key and just have be named bug tracker with the github link for the issues page.

I'll just use the one from pypi if there are multiple links gotten from regex

wasi-master commented 2 years ago

Fixed. Update to 1.3.1

pip install --upgrade pypi-command-line
wasi-master commented 2 years ago

By the way, I just discovered oxsphotos a few days ago. It's great. Thanks for making that :)