Skip to content

Commit b062a25

Browse files
committed
Add --max-rounds param in CLI
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent b46a8d0 commit b062a25

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/python_inspector/resolution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ def get_resolved_dependencies(
313313
environment: utils_pypi.Environment = None,
314314
repos: Sequence[utils_pypi.PypiSimpleRepository] = tuple(),
315315
as_tree: bool = False,
316+
max_rounds: int = 100,
316317
):
317318
"""
318319
Return resolved dependencies of a ``requirements`` list of Requirement for
@@ -326,6 +327,6 @@ def get_resolved_dependencies(
326327
provider=PythonInputProvider(environment=environment, repos=repos),
327328
reporter=BaseReporter(),
328329
)
329-
results = resolver.resolve(requirements=requirements)
330+
results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
330331
results = format_resolution(results, as_tree=as_tree)
331332
return results

src/python_inspector/resolve_cli.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@
101101
help="Write output as pretty-printed JSON to FILE. "
102102
"Use the special '-' file name to print results on screen/stdout.",
103103
)
104+
@click.option(
105+
"--max-rounds",
106+
"max_rounds",
107+
type=int,
108+
default=100,
109+
help="Increase the max rounds whenever the resolution is too deep",
110+
)
104111
@click.option(
105112
"--use-cached-index",
106113
is_flag=True,
@@ -128,6 +135,7 @@ def resolve_dependencies(
128135
operating_system,
129136
index_urls,
130137
json_output,
138+
max_rounds=100,
131139
use_cached_index=False,
132140
use_pypi_json_api=False,
133141
debug=TRACE,
@@ -220,6 +228,7 @@ def resolve_dependencies(
220228
environment=environment,
221229
repos=repos,
222230
as_tree=False,
231+
max_rounds=max_rounds,
223232
)
224233

225234
cli_options = [f"--requirement {rf}" for rf in requirement_files]
@@ -256,7 +265,7 @@ def resolve_dependencies(
256265
click.secho("done!")
257266

258267

259-
def resolve(direct_dependencies, environment, repos=tuple(), as_tree=False):
268+
def resolve(direct_dependencies, environment, repos=tuple(), as_tree=False, max_rounds=100):
260269
"""
261270
Resolve dependencies given a ``direct_dependencies`` list of
262271
DependentPackage and return a tuple of (initial_requirements,
@@ -273,6 +282,7 @@ def resolve(direct_dependencies, environment, repos=tuple(), as_tree=False):
273282
environment=environment,
274283
repos=repos,
275284
as_tree=as_tree,
285+
max_rounds=max_rounds,
276286
)
277287

278288
initial_requirements = [d.to_dict() for d in direct_dependencies]

0 commit comments

Comments
 (0)