pypistats.org icon indicating copy to clipboard operation
pypistats.org copied to clipboard

optional dependencies are incorrect

Open maartenbreddels opened this issue 2 years ago • 2 comments

Hi,

thanks for this project. I noticed on https://pypistats.org/packages/solara that it listed dask as a dependency, while it is only an optional dependency. Looking at: https://github.com/crflynn/pypistats.org/blob/70a10f994173b4b9e8905fb3494dd5d0d5bd1bbb/pypistats/views/general.py#L118 is too I see this check will not detect something like "dask[dataframe]; python_version < '3.7' and extra == 'dev'",

where the extra is not directly after the ;

Regards,

Maarten

maartenbreddels avatar Sep 15 '23 10:09 maartenbreddels

It might be better to use the packaging library (specifically packaging.requirements.Requirement for the parsing.

For example

from packaging.requirements import Requirement
r = Requirement("dask[dataframe]; python_version < '3.7' and extra=='dev'")
package_name = r.name
is_optional = ("extra == " in str(r.marker))  # the requirement gets normalised so there will always be spaces around the ==
print(package_name, is_optional)
# dask True

domdfcoding avatar Sep 18 '23 15:09 domdfcoding

Clearly the listing of required vs. optional packages is wrong. Since it seems to be an easy fix, @maartenbreddels @domdfcoding, why not create a pull request?

@crflynn there hasn't been a commit here in two years. Would a fix for this be merged?

mauvilsa avatar Feb 27 '24 21:02 mauvilsa