Fix local package detection for packages without top_level.txt#528
Fix local package detection for packages without top_level.txt#528datatalking wants to merge 1 commit into
Conversation
Adds fallback detection for .dist-info directories that lack top_level.txt (e.g., scipy, seaborn). Parses package name and version directly from the directory name when top_level.txt is missing. Fixes bndr#374 Co-Authored-By: datatalking <datatalking@users.noreply.github.com>
StantonMatt
left a comment
There was a problem hiding this comment.
I checked this locally because #374 has a long trail of reports around packages like scipy/seaborn missing top_level.txt, and the fallback does cover that core shape.
With a synthetic scipy-1.9.3.dist-info directory and no top_level.txt:
origin/master packages []
origin/master import local []
pr-528 packages [{'name': 'scipy', 'version': '1.9.3', 'exports': ['scipy']}]
pr-528 import local [{'name': 'scipy', 'version': '1.9.3', 'exports': ['scipy']}]
So the intended local-detection path works in that direct repro. The branch does need a bit more test work before I would call it ready, though. Full local discovery currently fails:
python -m unittest discover
FAILED (failures=1)
The failing test is tests.test_pipreqs.TestPipreqs.test_init_local_only. In my environment, --use-local now writes:
beautifulsoup4==4.14.3
docopt==0.6.2
ipython==8.18.1
pyflakes==3.4.0
The new beautifulsoup4 entry comes from the existing bs4 import mapping plus the new fallback seeing beautifulsoup4-4.14.3.dist-info without top_level.txt. That may be intended behavior, but the test expectation has not been updated, and there is not yet a committed regression test for the scipy/seaborn-style no-top_level.txt case.
Other checks passed:
python -m py_compile pipreqs/pipreqs.py tests/test_pipreqs.py
python -m flake8 pipreqs/pipreqs.py tests/test_pipreqs.py
git diff --check origin/master...HEAD
GitHub reports no check runs for this PR. I think the next step is to add a small fixture/regression test for a .dist-info directory without top_level.txt, and either update test_init_local_only for the now-detected beautifulsoup4 output or adjust the fallback if that output is not desired.
|
@datatalking, @StantonMatt: Just some thoughts - I guess you thought your self about and had good reasons not to go this route.
EditI checked pyserial - a package i know is to be imported as |
Adds fallback detection for .dist-info directories that lack top_level.txt (e.g., scipy, seaborn). Parses package name and version directly from the directory name when top_level.txt is missing.
Fixes #374