aboutcode-org / python-inspector

Inspect Python code and PyPI package manifests. Resolve Python dependencies.
22 stars 19 forks source link

Conflicts with python versions on patch level #103

Open oheger-bosch opened 1 year ago

oheger-bosch commented 1 year ago

We have a requirements.txt file that cannot be analyzed by Python Inspector due to conflicting dependencies. It boils down to the following two dependencies:

anyio==3.6.1
dataclasses==0.8

When running the command python-inspector -r requirements.txt --json-pdt - -o linux -p 36 it reports

raise ResolutionImpossible(e.criterion.information)
resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=<Requirement('anyio==3.6.1')>, parent=None)]

When choosing a different Python version, e.g. 37 the problem is caused by the dataclasses library (see full stack trace below).

From what I found out, there seem to be only specific Python versions for which this constellation can work: dataclasses requires Python >=3.6, <3.7; anyio requires Python >=3.6.2. It is, however, not possible to define the Python version for Python Inspector on that level of detail. I assume that the 36 option will select a 3.6.0 version? So, should the corresponding option be extended to support an exact version number? Or is there another way how to solve this issue?

Here is the full stack trace:

Traceback (most recent call last):
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/resolvelib/resolvers.py", line 372, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/resolvelib/resolvers.py", line 173, in _add_to_criteria
    raise RequirementsConflicted(criterion)
resolvelib.resolvers.RequirementsConflicted: Requirements conflict: <Requirement('dataclasses==0.8')>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/python_inspector/resolve_cli.py", line 246, in resolve_dependencies
    resolution_result: Dict = resolver_api(
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/python_inspector/api.py", line 257, in resolve_dependencies
    resolution, purls = resolve(
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/python_inspector/api.py", line 316, in resolve
    resolved_dependencies, packages = get_resolved_dependencies(
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/python_inspector/api.py", line 354, in get_resolved_dependencies
    resolver_results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/resolvelib/resolvers.py", line 521, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/heo1wa3/.local/lib/python3.8/site-packages/resolvelib/resolvers.py", line 374, in resolve
    raise ResolutionImpossible(e.criterion.information)
resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=<Requirement('dataclasses==0.8')>, parent=None)]
pombredanne commented 1 year ago

@oheger-bosch Excellent catch! we should also use simpler way to state a version (e.g. using the actual fully dotted version)

kerstin-bosch commented 1 year ago

Hi @pombredanne, have you already thought about this, maybe even worked on an implementation/solution? FYI: @oheger-bosch

pombredanne commented 1 year ago

@kerstin-bosch I have looked into the details but no fix yet. This is a couple days of work.

ghost commented 1 year ago

Hi @pombredanne Do you have any updates for us? Is the fix already implemented?