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

Work around top-level venv special case #468

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jherland
Copy link
Member

This should solve issues #465.

Add special handling for the case were we have found a Python environment rooted at the same directory where we have been asked to look for code and/or deps.

Commits:

@jherland jherland added this to the FawltyDeps 1.0 milestone Jan 28, 2025
@jherland jherland self-assigned this Jan 28, 2025
@jherland jherland linked an issue Jan 28, 2025 that may be closed by this pull request
@jherland jherland force-pushed the jherland/top-level-venv branch from 8bb16b1 to 339aaf7 Compare January 28, 2025 18:06
@jherland jherland force-pushed the jherland/top-level-venv branch from 339aaf7 to e0bb9f2 Compare February 21, 2025 11:27
This sample project has a virtualenv in the same directory as the
project itself. Currently this causes FawltyDeps to find zero code and
zero dependencies in the project.
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.
@jherland jherland force-pushed the jherland/top-level-venv branch from e0bb9f2 to 01b07c2 Compare February 27, 2025 15:28
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

Successfully merging this pull request may close these issues.

top-level venv doesn't work
1 participant