aboutcode-org / python-inspector

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

Getting `ImportError: cannot import name 'splat'` with `setuptools` 75.0.0 #190

Open sschuberth opened 2 months ago

sschuberth commented 2 months ago

We started to see this in ORT:

    java.io.IOException: Running 'python-inspector --python-version 311 --operating-system linux --json-pdt /tmp/ort-PythonInspector15711813311588694259/python-inspector5969974550712099055.json --requirement /workspace/plugins/package-managers/python/src/funTest/assets/projects/synthetic/python-inspector-no-analyze-setup-py/requirements.txt --verbose' in '/workspace/plugins/package-managers/python/src/funTest/assets/projects/synthetic/python-inspector-no-analyze-setup-py' failed with exit code 1:
    Traceback (most recent call last):
      File "/opt/python/versions/3.11.9/bin/python-inspector", line 8, in <module>
        sys.exit(resolve_dependencies())
                 ^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
        return self.main(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/click/core.py", line 1078, in main
        rv = self.invoke(ctx)
             ^^^^^^^^^^^^^^^^
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
        return ctx.invoke(self.callback, **ctx.params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/click/core.py", line 783, in invoke
        return __callback(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
        return f(get_current_context(), *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/python_inspector/resolve_cli.py", line 224, in resolve_dependencies
        from python_inspector.api import resolve_dependencies as resolver_api
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/python_inspector/api.py", line 33, in <module>
        from python_inspector.package_data import get_pypi_data_from_purl
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/python_inspector/package_data.py", line 22, in <module>
        from python_inspector.resolution import get_python_version_from_env_tag
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/python_inspector/resolution.py", line 41, in <module>
        from python_inspector.setup_py_live_eval import iter_requirements
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/python_inspector/setup_py_live_eval.py", line 21, in <module>
        import distutils.core
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 13, in <module>
        from .cmd import Command
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 12, in <module>
        from . import _modified, archive_util, dir_util, file_util, util
      File "/opt/python/versions/3.11.9/lib/python3.11/site-packages/setuptools/_distutils/_modified.py", line 6, in <module>
        from jaraco.functools import splat
    ImportError: cannot import name 'splat' from 'jaraco.functools' (/opt/python/versions/3.11.9/lib/python3.11/site-packages/jaraco/functools.py)

Is this a known issue with Python 3.11.9?

sschuberth commented 2 months ago

BTW, this is for PI version 0.10.0 which we're still stuck on due to this regression.

sschuberth commented 2 months ago

As @mnonnenmacher found out, this seemingly is related to setuptools 75.0.0 adding jaraco.collections.