Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible feature contribution: Detect 'risky' packages whose names present in local directory. #446

Open
edx-h opened this issue Apr 30, 2024 · 0 comments

Comments

@edx-h
Copy link

edx-h commented Apr 30, 2024

Background:
Here is a simple directory tree for illustration purpose.

.
├── script.py
└── wandb

In script.py. I have a line to import wandb, import wandb.
When I execute pipreqs on ./, it lists all packages but wandb. I guess it is due to pipreqs believes wandb is not an external dependency because of its presence in the directory. Perhaps it is recognised as a locally developed package.

However in this case, given wandb is a prevailing external package for deep learning and the local wandb folder is empty, it can be deduced that wandb is bound to be an external dependent. In fact, I think it is common that folder / file in the directory shares same name with some external packages. In such case, those packages will not be detected.

Trouble shooting:
packages = imports - (set(candidates) & imports)
The case is due to the above line in function get_all_imports in pipreqs.py. Since wandb is the intersection between candidates and imports, it is finally eliminated from imports

Solution:
I believe that elements like wandb in this example are identified as risky, because they are not only registered in PyPI, but also filed locally. They should not be added to requirements.txt directly, which I totally agree. However, is it possible to add a feature to identify those risky packages and output them to another file? Additionally, printing debug info can also be considered.

If this idea is reasonable, I can contribute on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant