Safe name for consistency with PyPI standards?
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
According to PyPI standards, any package name chosen will be normalized with the [`safe_name`](../../../pypa/setuptools/blob/9755c3bc2bf1fe50bf67dccb583ffad9d57f7bab/pkg_resources/__init__.py#L1312) function to a standard distribution name, where all non-alphanumeric excluding period are replaced with the hyphen (`-`). As a result, an inconsistency appears for packages such as `mpl_finance`. That is `pip freeze` would return `mpl-finance==0.10.0`, while `pipreqs --print '...'` would return `mpl_finance==0.10.0`. Supposedly, this happens because `pipreqs` blindly assumes that the package name is the same as appears in an `import` statement, which is clearly wrong. Either the actual package name should be obtained by checking the corresponding installation (eggs/wheels) or (probably simpler) by applying `safe_name` to the package name as it appears in an `import` statement.
Contributor guide
Research direction
Start at the pipreqs --print path that converts import names into requirements, using the mpl_finance example from the issue. Read the referenced setuptools safe_name function and compare pipreqs output with pip freeze; done means the generated requirement uses the normalized distribution name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100