Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
traverse_project: Better handle overlap between pyenv and code/deps dir
Issue #465 highlights a peculiar case where the top-level project directory is also itself the root of a virtualenv. Our traversal code will skip any (given or detected) Python environment, under the assumption that we never want to analyze code/deps from a package installed within. However, we here have a special case where -- from the traversal code's POV -- we have found a pyenv rooted at a directory that also appears in the given settings.code and/or settings.deps (by default settings.code, settings.deps and settings.pyenvs are all "."). Work around this special case as follows: When a Python environment is found rooted at a path that is _also_ directly given in either settings.code or settings.deps, then we _don't_ want to skip traversal of the entire directory, rather we only skip traversal of the specific subdirectories that form the actual contents of the environment: - Any package dirs found by validate_pyenv_source() (i.e. any "site-packages" dirs). - The "bin/" (or "Scripts\" on Windows) subdir where we expect to find any tools installed into the environment. We could probably extend this handling to _any_ Python environment (including those found after we start the traversal proper), but I'm not 100% sure that this won't trigger false positives where some weird Python environment (e.g. a Conda or poetry2nix environment) happens to contain extra "stuff" missing from the above list that would adversely affect our analysis.
- Loading branch information