pipreqs
pipreqs copied to clipboard
Pip reqs doesn't work when import is not the same as the library name
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:
- import
ahorasick
into<file>.py
in<dir>
- run
pipreqs <dir>
- See there is both
ahorasick
(incorrect) andpyahorasick
(correct) - run
pip install -r <dir>/requirements.txt
- 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 😄
Hello,
I can confirm this with the pygithub
module.
It is not detected, as the import is import github
.
I'm also grateful for any workarounds when it is not as easy to detect.
pyahoarsick
library is newer than the last commit in pipreqs
repository. You should update MAPPING file.
As for github
module, it is present in mapping file on line 681:
github:PyGithub
and this I do not understand.
Yes, I saw the mapping too, but it somehow did not work.
I have to correct, now with version 0.4.11 it works like a charm