davep / pispy

A terminal-based tool for looking up stuff in PyPI
https://pypi.org/project/pispy-client/
GNU General Public License v3.0
24 stars 2 forks source link

Distinguish core and optional dependencies #20

Open TomJGooding opened 4 months ago

TomJGooding commented 4 months ago

It might be nice to distinguish between core and optional dependencies in the Requires section.

For example, the textual package shows tree-sitter and tree-sitter-languages which are optional extras. Other packages may have defined separate dev only dependencies.

davep commented 4 months ago

Aye, nice idea. I'll add that the next time I stream working on this; seems like a nice self-contained change.

davep commented 4 months ago

Note to self: see also #24 from @hugovk - like, sorting is a nice thing to do for folk! (Nobody ask why I didn't do that in the first place).

davep commented 4 months ago

Note to self: Also noting #25 too it might make sense to tidy up all of this by using Packaging instead.

davep commented 4 months ago

Looking into the options, either I'm missing the obvious here, or neither of parse_requirements nor Requirement in Package provide a way of getting at that extra value:

    "requires_dist": [
      "markdown-it-py[linkify,plugins]>=2.1.0",
      "rich>=13.3.3",
      "typing-extensions<5.0.0,>=4.4.0",
      "tree-sitter<0.21.0,>=0.20.1; extra == \"syntax\"",
      "tree-sitter-languages==1.10.2; extra == \"syntax\""
    ],

There also seems to be nothing in the metadata as acquired from the metadata that says "oh yeah there's this syntax thing you might want to say you want...".

TomJGooding commented 4 months ago

I confess I haven't really looked into this in any detail, but perhaps you could use the Requirement.marker?

But now looking at all the possible markers, I've realised it isn't as simple as distinguishing core and extra dependencies, as some might depend on the OS, Python versions, etc. I'm not sure a tool like PISpy should really be expected to drill down to this level of detail...

davep commented 4 months ago

Yup, was playing around with that this morning. While I've not reached a final conclusion on on it, I think I'm falling down on the side of this not really being a handy thing for PISpy (albeit I am considering a consolidated vs detailed dependency display toggle).

TomJGooding commented 4 months ago

Sorry I hadn't really considered all the possible dependency "depends" when I suggested this! A consolidated vs detailed dependency display toggle would be a nice feature but only if it isn't too much work.