Having a subfolder with the same name as a package will silently prevent that package from being added to requirements.txt. For example, having a subfolder called yaml in a repository will prevent PyYaml from being added. This appears to be the issue in
181 and #187.
One (partial) solution would be to check if the folder contains __init__.py, and if it does not, remove it from the candidates list in the get_all_imports() function , as it cannot (or at least shouldn't) be used as an import anyway. Another feature that could be helpful would be to check for items that are common to both imports and candidates, and then check if they map to a valid PyPi package, and then emit a warning that they are being suppressed.
I'm unsure if this could lead to unintended effects or break existing applications, but if this seems like a good idea I'm happy to implement it myself and submit a PR.
Having a subfolder with the same name as a package will silently prevent that package from being added to
requirements.txt
. For example, having a subfolder calledyaml
in a repository will preventPyYaml
from being added. This appears to be the issue in181 and #187.
One (partial) solution would be to check if the folder contains
__init__.py
, and if it does not, remove it from thecandidates
list in theget_all_imports()
function , as it cannot (or at least shouldn't) be used as an import anyway. Another feature that could be helpful would be to check for items that are common to bothimports
andcandidates
, and then check if they map to a valid PyPi package, and then emit a warning that they are being suppressed.I'm unsure if this could lead to unintended effects or break existing applications, but if this seems like a good idea I'm happy to implement it myself and submit a PR.