tweag / FawltyDeps

Python dependency checker
Other
201 stars 14 forks source link

When I install setuptools==71.0.1,FavltyDeps will not found it name #444

Closed XDeviation closed 4 months ago

XDeviation commented 4 months ago

Describe the bug Environment:

when I run fawltydeps, it will raise error:

Traceback (most recent call last):
  File "/home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/fawltydeps/packages.py", line 239, in _from_one_env
    normalized_name = Package.normalize_name(dist.name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/fawltydeps/packages.py", line 80, in normalize_name
    return package_name.lower().replace("-", "_")
           ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'

I add some try except to this code, and I found that It failed to parse setuptools, see this log:

  File "/home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/fawltydeps/utils.py", line 71, in wrapper
    calculated: T = method(self)
                    ^^^^^^^^^^^^
  File "/home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/fawltydeps/packages.py", line 300, in packages
    return accumulate_mappings(self.__class__, self._from_one_env(sys.path))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/fawltydeps/packages.py", line 130, in accumulate_mappings
    for custom_mapping, debug_key in custom_mappings:
  File "/home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/fawltydeps/packages.py", line 241, in _from_one_env
    raise BaseException(dist._path)
BaseException: /home/lost/.cache/pypoetry/virtualenvs/doc-engine-KIm15ka8-py3.12/lib/python3.12/site-packages/setuptools/_vendor/importlib_metadata-8.0.0.dist-info

To Reproduce Install setuptools == 68.0.0

Expected behavior Add setuptools lock

Environment

Additional context Add any other context about the problem here.

jherland commented 4 months ago

Thanks for reporting. I tried to reproduce locally with setuptools==71.0.1, and I found similar issues to what you report above (I don't know which project/context you're running in, or what options/configuration you are using, so I did not get the exact same traceback).

However, it seems that the metadata shipped with setuptools==71.0.1 is faulty, and this is the cause of this error. Indeed, the 71.0.1 release has been yanked from PyPI, as noted in this warning message when I install 71.0.1.

$ .venv_test/bin/pip install setuptools==71.0.1
Collecting setuptools==71.0.1
  Downloading setuptools-71.0.1-py3-none-any.whl.metadata (6.5 kB)
WARNING: The candidate selected for download or install is a yanked version: 'setuptools' candidate (version 71.0.1 at https://files.pythonhosted.org/packages/39/11/6159cc30f99dbdccac3c74d67277505d0e0bfc059e6cc57ef2eefc9b8751/setuptools-71.0.1-py3-none-any.whl (from https://pypi.org/simple/setuptools/) (requires-python:>=3.8))
Reason for being yanked: https://github.com/pypa/setuptools/issues/4480
...

If I use any surrounding setuptools version instead (I've tested 71.0.0, 71.0.2, and 71.0.3) I am not able to reproduce this issue at all. So I believe this issue is caused by the faulty metadata in setuptools (see https://github.com/pypa/setuptools/issues/4480 for the upstream issue), and since this release has already been yanked and replaced with newer/working versions, I consider this issue resolved.