`get_locally_installed_packages()` misses packages built with modern PEP-517 backends (flit, hatchling) due to missing `top_level.txt`
The Bug
When running pipreqs --use-local, the tool fails to detect certain installed packages in the local environment, resulting in those dependencies being entirely omitted from the generated requirements.txt.
Root Cause Analysis
Currently, get_locally_installed_packages() determines local package mappings by scanning the site-packages directory for dist-info or egg-info folders and reading the top_level.txt file.
While legacy setuptools builds generate top_level.txt, modern PEP-517 build backends (such as flit, hatchling, and poetry-core) do not reliably generate or ship this file. When pipreqs encounters these modern packages, the os.path.exists(top_level_filepath) check fails silently, and the package is skipped entirely during the local scan.
Source: bndr/pipreqs