Skip to content

Commit 2da0445

Browse files
committed
main: Use PyEnvSource objects when resolving dependencies
This starts requesting PyEnvSource objects when we call traverse_project.find_sources(), and pass the paths from these object on to resolve_dependencies(). In other words, this commit is when we first start actually using the new traversal logic for Python environments in FawltyDeps. On the test side, we can finally remove the overly explicit specification needed to correctly traverse/parse the pyenv_galore sample project. Instead, this project is now successfully handled with default settings: - pyenvs set to the project root is able to auto-detect all the Python environments found within. - As a result, there is no code, nor any deps files found (since the project consists of Python environments only).
1 parent a695088 commit 2da0445

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

fawltydeps/main.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
DeclaredDependency,
3131
DepsSource,
3232
ParsedImport,
33+
PyEnvSource,
3334
Source,
3435
UndeclaredDependency,
3536
UnparseablePathException,
@@ -73,8 +74,8 @@ def sources(self) -> Set[Source]:
7374
source_types: Dict[Action, Set[Type[Source]]] = {
7475
Action.LIST_IMPORTS: {CodeSource},
7576
Action.LIST_DEPS: {DepsSource},
76-
Action.REPORT_UNDECLARED: {CodeSource, DepsSource},
77-
Action.REPORT_UNUSED: {CodeSource, DepsSource},
77+
Action.REPORT_UNDECLARED: {CodeSource, DepsSource, PyEnvSource},
78+
Action.REPORT_UNUSED: {CodeSource, DepsSource, PyEnvSource},
7879
}
7980
return set(
8081
find_sources(
@@ -112,7 +113,9 @@ def resolved_deps(self) -> Dict[str, Package]:
112113
(dep.name for dep in self.declared_deps),
113114
custom_mapping_files=self.settings.custom_mapping_file,
114115
custom_mapping=self.settings.custom_mapping,
115-
pyenv_paths=self.settings.pyenvs,
116+
pyenv_paths={
117+
src.path for src in self.sources if isinstance(src, PyEnvSource)
118+
},
116119
install_deps=self.settings.install_deps,
117120
)
118121

tests/sample_projects/pyenv_galore/expected.toml

+1-13
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,7 @@ description = """
1111

1212
[experiments.default]
1313
description = "Run fawltydeps in an empty project with Python envs present."
14-
15-
# TODO: Auto-detect all Python environments in this project, and use those to
16-
# eliminate the discovery of code/deps within those environments. For now:
17-
# explcitly disable code/deps, and list all Python environments in project.
18-
code = []
19-
deps = []
20-
pyenvs = [
21-
"poetry2nix_result",
22-
"__pypackages__",
23-
".venv",
24-
"another-venv",
25-
]
26-
# TODO: pyenvs = [""] # Find all Python environments inside project
14+
pyenvs = [""] # Find all Python environments in project
2715

2816
# 3rd-party imports found in the code:
2917
imports = []

0 commit comments

Comments
 (0)