Merge pull request #22 from enpaul/enp/recursive

Fix recursive dependencies causing recursion error
This commit is contained in:
Ethan Paul 2020-11-12 00:26:22 -05:00 committed by GitHub
commit d1f161e0fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
"""Helper utility functions, usually bridging Tox and Poetry functionality""" """Helper utility functions, usually bridging Tox and Poetry functionality"""
from pathlib import Path from pathlib import Path
from typing import List
from typing import Sequence from typing import Sequence
from typing import Set from typing import Set
@ -109,21 +108,22 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac
""" """
try: try:
top_level = packages[dependency_name]
def find_deps_of_deps(name: str) -> List[PoetryPackage]: def find_deps_of_deps(name: str, transients: PackageMap):
if name in PoetryProvider.UNSAFE_PACKAGES: if name in PoetryProvider.UNSAFE_PACKAGES:
reporter.warning( reporter.warning(
f"{constants.REPORTER_PREFIX} installing package '{name}' using Poetry is not supported; skipping installation of package '{name}'" f"{constants.REPORTER_PREFIX} installing package '{name}' using Poetry is not supported; skipping installation of package '{name}'"
) )
return [] else:
transients = [packages[name]] transients[name] = packages[name]
for dep in packages[name].requires: for dep in packages[name].requires:
transients += find_deps_of_deps(dep.name) if dep.name not in transients.keys():
return transients find_deps_of_deps(dep.name, transients)
return set(find_deps_of_deps(top_level.name)) transients: PackageMap = {}
find_deps_of_deps(packages[dependency_name].name, transients)
return set(transients.values())
except KeyError: except KeyError:
if any( if any(
delimiter in dependency_name delimiter in dependency_name