pypistats.org
pypistats.org copied to clipboard
optional dependencies are incorrect
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
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
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?