aboutcode-org / python-inspector

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

Running `python-inspector` gives `KeyError: 'dictionary is empty'` #169

Open sschuberth opened 9 months ago

sschuberth commented 9 months ago

This comes from ORT running

python-inspector --python-version 311 --operating-system linux --json-pdt /tmp/ort-PythonInspector1958014688763264125/python-inspector6282585536190674410.json --analyze-setup-py-insecurely --requirement /var/jenkins_home/workspace/ORT@tmp/project/source/anonymizer_module/test_requirements.txt --setup-py /var/jenkins_home/workspace/ORT@tmp/project/source/anonymizer_module/setup.py --verbose

on https://github.com/nordic-institute/X-Road-Metrics/blob/ce07b95f1fc6fe8236a1d4f6e3bed95b84d313a4/anonymizer_module/test_requirements.txt, see

PIP failed to resolve dependencies for path 'anonymizer_module/test_requirements.txt': IOException: Running 'python-inspector --python-version 311 --operating-system linux --json-pdt /tmp/ort-PythonInspector1958014688763264125/python-inspector6282585536190674410.json --analyze-setup-py-insecurely --requirement /var/jenkins_home/workspace/ORT@tmp/project/source/anonymizer_module/test_requirements.txt --setup-py /var/jenkins_home/workspace/ORT@tmp/project/source/anonymizer_module/setup.py --verbose' in '/var/jenkins_home/workspace/ORT@tmp/project/source/anonymizer_module' failed with exit code 1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/resolvelib/resolvers.py", line 316, in _backjump
    name, candidate = broken_state.mapping.popitem()
KeyError: 'dictionary is empty'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/python_inspector/resolve_cli.py", line 253, in resolve_dependencies
    resolution_result: Dict = resolver_api(
  File "/usr/local/lib/python3.10/dist-packages/python_inspector/api.py", line 279, in resolve_dependencies
    resolution, purls = resolve(
  File "/usr/local/lib/python3.10/dist-packages/python_inspector/api.py", line 341, in resolve
    resolved_dependencies, packages = get_resolved_dependencies(
  File "/usr/local/lib/python3.10/dist-packages/python_inspector/api.py", line 379, in get_resolved_dependencies
    resolver_results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
  File "/usr/local/lib/python3.10/dist-packages/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/usr/local/lib/python3.10/dist-packages/resolvelib/resolvers.py", line 434, in resolve
    success = self._backjump(causes)
  File "/usr/local/lib/python3.10/dist-packages/resolvelib/resolvers.py", line 318, in _backjump
    raise ResolutionImpossible(causes)
resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=<Requirement('pymongo==3.10.1')>, parent=None), RequirementInformation(requirement=<Requirement('pymongo<4.0,>=3.11')>, parent=Candidate(name='pymongo-stubs', version=<Version('0.2.0')>, extras=set())), RequirementInformation(requirement=<Requirement('pymongo==3.10.1')>, parent=None), RequirementInformation(requirement=<Requirement('pymongo<4.0,>=3.11')>, parent=Candidate(name='pymongo-stubs', version=<Version('0.1.0')>, extras=set()))]
pombredanne commented 9 months ago

@sschuberth Thanks for the report!

sschuberth commented 8 months ago

Looks like the issue disappeared with python-inspector release 0.11.0.

sschuberth commented 8 months ago

Sorry, no, I was not seeing the issue for another reason, but it's still there.