Pip reqs doesn't work when import is not the same as the library name
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
Hello, found a bug when the module name to import is not the same as the library name, in this case the `pyahorasick` library.
To reproduce:
1. import `ahorasick` into `.py` in ``
2. run `pipreqs `
3. See there is both `ahorasick` (incorrect) and `pyahorasick` (correct)
4. run `pip install -r /requirements.txt`
5. See an error that no versions of `ahorasick` can be found.
`ahorasick` is the module from within the `pyahorasick` library. What I am guessing is happening is `pipreqs` is building the requirements based off import statements, and because in this case module name != library name it incorrectly requires `ahorasick`, and as that does not exists on pypi, results in an error.
Happy to (attempt to) contribute if someone can point me in the right direction 😄
Contributor guide
Research direction
Start with the pipreqs command and reproduce the import scan using ahorasick from pyahorasick. Trace how imported module names become entries in requirements.txt, then verify that the generated file contains pyahorasick without the invalid ahorasick package and can be installed successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100