Python inspector command fails when requirements.txt includes sys_platform

Open
#246 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Reproduce the failure with the shown python-inspector command and requirements.txt, then inspect python_inspector/resolution.py around find_matches and _iter_matches, following the call from python_inspector/api.py. Done means the command completes for the sys_platform requirement and resolves torch==2.8.0 for the shown macOS case without raising NoVersionsFound.

Written by the indexing model from the issue text.

Description

Python inspector command fails to scan when some packages include system platform information:

>python-inspector --requirement requirements.txt -p 313 -o macos --json-pdt tmp.json

Traceback (most recent call last):
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/python_inspector/resolve_cli.py", line 259, in resolve_dependencies
    resolution_result: Dict = resolver_api(
                              ~~~~~~~~~~~~^
        requirement_files=requirement_files,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<15 lines>...
        generic_paths=generic_paths,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/python_inspector/api.py", line 283, in resolve_dependencies
    resolution, purls = resolve(
                        ~~~~~~~^
        direct_dependencies=direct_dependencies,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
        printer=printer,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/python_inspector/api.py", line 374, in resolve
    resolved_dependencies, packages = get_resolved_dependencies(
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~^
        requirements=requirements,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
        printer=printer,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/python_inspector/api.py", line 465, in get_resolved_dependencies
    resolver_results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/resolvelib/resolvers/resolution.py", line 596, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/resolvelib/resolvers/resolution.py", line 429, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/resolvelib/resolvers/resolution.py", line 125, in _add_to_criteria
    matches = self._p.find_matches(
        identifier=identifier,
    ...<9 lines>...
        ),
    )
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/python_inspector/resolution.py", line 634, in find_matches
    candidates = sorted(
        self._iter_matches(identifier, requirements, incompatibilities),
        key=operator.attrgetter("version"),
        reverse=True,
    )
  File "~/Documents/misc/python-torch-multi-platform/.venv/lib/python3.13/site-packages/python_inspector/resolution.py", line 617, in _iter_matches
    raise NoVersionsFound(f"This package does not exist: {name}")
python_inspector.error.NoVersionsFound: This package does not exist: torch

The requirements.txt file (https://github.com/voidpetal/pyinsp-system-platform-test/tree/main):

torch==2.8.0; sys_platform != "linux"
Dominant language
Python
Stars
23
Forks
29
Avg merge
1h 7m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/python-inspector

All issues in aboutcode-org/python-inspector

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.