aboutcode-org / python-inspector

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

ImportError: Cython not found! when inspecting `hdbscan==0.8.33` #155

Open fviernau opened 1 year ago

fviernau commented 1 year ago

Question: Is this something which can be fixed in python inspector? Or does this need a fix in the dependency?

The following reproduces with version 0.10.0:

  1. Setup a requirements.txt:

    hdbscan==0.8.33 ; python_version >= "3.11" and python_version < "4.0"
  2. Run inspection like:

    
    python-inspector --python-version 311 --operating-system linux --json-pdt x.json --analyze-setup-py-insecurely --requirement r.txt
    Warning: ambiguous setup provider in /workspace/.cache/python_inspector/extracted_sdists/hdbscan-0.8.33/hdbscan-0.8.33/setup.py: candidates are ['setuptools', 'setuptools']defaulting to 'distutils.core'.
    <string>:8: UserWarning: No module named 'Cython'
    <string>:92: UserWarning: Due to incompatibilities with Python 3.7 hdbscan nowrequires Cython to be installed in order to build it
    Traceback (most recent call last):
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/resolve_cli.py", line 253, in resolve_dependencies
    resolution_result: Dict = resolver_api(
                              ^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/api.py", line 279, in resolve_dependencies
    resolution, purls = resolve(
                        ^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/api.py", line 341, in resolve
    resolved_dependencies, packages = get_resolved_dependencies(
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/api.py", line 379, in get_resolved_dependencies
    resolver_results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/resolvelib/resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/resolvelib/resolvers.py", line 239, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/resolvelib/resolvers.py", line 229, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/resolution.py", line 644, in get_dependencies
    return list(self._iter_dependencies(candidate))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/resolution.py", line 635, in _iter_dependencies
    for r in self.get_requirements_for_package(purl=purl, candidate=candidate):
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/resolution.py", line 497, in get_requirements_for_package_from_pypi_simple
    yield from get_reqs_insecurely(
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/resolution.py", line 277, in get_reqs_insecurely
    yield from parse_reqs_from_setup_py_insecurely(setup_py=setup_py_location)
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/resolution.py", line 128, in parse_reqs_from_setup_py_insecurely
    for req in iter_requirements(level="", extras=[], setup_file=setup_py):
    File "/opt/python/versions/3.11.5/lib/python3.11/site-packages/python_inspector/setup_py_live_eval.py", line 117, in iter_requirements
    exec(file_contents, g)
    File "<string>", line 94, in <module>
    ImportError: Cython not found! Please install cython and try again