Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/python_inspector/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def resolve_dependencies(
analyze_setup_py_insecurely=False,
prefer_source=False,
printer=print,
ignore_errors=False,
):
"""
Resolve the dependencies for the package requirements listed in one or
Expand Down Expand Up @@ -268,6 +269,7 @@ def resolve_dependencies(
max_rounds=max_rounds,
pdt_output=pdt_output,
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
ignore_errors=ignore_errors,
)

packages = []
Expand Down Expand Up @@ -302,6 +304,7 @@ def resolve(
max_rounds=200000,
pdt_output=False,
analyze_setup_py_insecurely=False,
ignore_errors=False,
):
"""
Resolve dependencies given a ``direct_dependencies`` list of
Expand All @@ -327,6 +330,7 @@ def resolve(
max_rounds=max_rounds,
pdt_output=pdt_output,
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
ignore_errors=ignore_errors,
)

return resolved_dependencies, packages
Expand All @@ -340,6 +344,7 @@ def get_resolved_dependencies(
max_rounds: int = 200000,
pdt_output: bool = False,
analyze_setup_py_insecurely: bool = False,
ignore_errors: bool = False,
):
"""
Return resolved dependencies of a ``requirements`` list of Requirement for
Expand All @@ -354,6 +359,7 @@ def get_resolved_dependencies(
environment=environment,
repos=repos,
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
ignore_errors=ignore_errors,
),
reporter=BaseReporter(),
)
Expand Down
11 changes: 8 additions & 3 deletions src/python_inspector/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def get_requirements_from_python_manifest(

class PythonInputProvider(AbstractProvider):
def __init__(
self, environment=DEFAULT_ENVIRONMENT, repos=tuple(), analyze_setup_py_insecurely=False
self, environment=DEFAULT_ENVIRONMENT, repos=tuple(), analyze_setup_py_insecurely=True,
ignore_errors=False
):
self.environment = environment
self.environment_marker = get_environment_marker_from_environment(self.environment)
Expand All @@ -361,6 +362,7 @@ def __init__(
self.dependencies_by_purl = {}
self.wheel_or_sdist_by_package = {}
self.analyze_setup_py_insecurely = analyze_setup_py_insecurely
self.ignore_errors = ignore_errors

def identify(self, requirement_or_candidate: Union[Candidate, Requirement]) -> str:
"""Given a requirement, return an identifier for it. Overridden."""
Expand Down Expand Up @@ -583,8 +585,11 @@ def _iter_matches(
versions.extend(self.get_versions_for_package(name=name, repo=repo))

if not versions:
raise NoVersionsFound(f"This package does not exist: {name}")

if self.ignore_errors:
yield from [Candidate("NonExistant", "0.0.0", "")]
return
else:
raise NoVersionsFound(f"This package does not exist: {name}")
yield from self.get_candidates(
all_versions=versions,
requirements=requirements,
Expand Down
3 changes: 3 additions & 0 deletions src/python_inspector/resolve_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def print_version(ctx, param, value):
callback=print_version,
help="Show the version and exit.",
)
@click.option('--ignore-errors', is_flag=True, default=False, help='Ignore errors and continue execution.')
@click.help_option("-h", "--help")
def resolve_dependencies(
ctx,
Expand All @@ -190,6 +191,7 @@ def resolve_dependencies(
analyze_setup_py_insecurely=False,
prefer_source=False,
verbose=TRACE,
ignore_errors=False,
):
"""
Resolve the dependencies for the package requirements listed in one or
Expand Down Expand Up @@ -260,6 +262,7 @@ def resolve_dependencies(
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
printer=click.secho,
prefer_source=prefer_source,
ignore_errors=ignore_errors,
)
output = dict(
headers=headers,
Expand Down