explosion / catalogue

Super lightweight function registries for your library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Importlib issue with python3.10

rmcgibbo opened this issue · comments

I'm seeing an issue running the tests with python3.10. The error is

python3.10-catalogue> ============================= test session starts ==============================
python3.10-catalogue> platform linux -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
python3.10-catalogue> rootdir: /build/catalogue-2.0.6
python3.10-catalogue> collected 8 items
python3.10-catalogue> catalogue/tests/test_catalogue.py ......F.                               [100%]
python3.10-catalogue> =================================== FAILURES ===================================
python3.10-catalogue> ______________________________ test_entry_points _______________________________
python3.10-catalogue>     def test_entry_points():
python3.10-catalogue>         # Create a new EntryPoint object by pretending we have a setup.cfg and
python3.10-catalogue>         # use one of catalogue's util functions as the advertised function
python3.10-catalogue>         ep_string = "[options.entry_points]test_foo\n    bar = catalogue:check_exists"
python3.10-catalogue> >       ep = catalogue.importlib_metadata.EntryPoint._from_text(ep_string)
python3.10-catalogue> E       AttributeError: type object 'EntryPoint' has no attribute '_from_text'
python3.10-catalogue> catalogue/tests/test_catalogue.py:108: AttributeError
python3.10-catalogue> =========================== short test summary info ============================
python3.10-catalogue> FAILED catalogue/tests/test_catalogue.py::test_entry_points - AttributeError:...

The same route works fine with python3.9. Here's a full log from the NixOS CI system: https://hydra.nixos.org/log/pfyk1v5fl14yf1n31v8ppjknqxwzgrgm-python3.10-catalogue-2.0.6.drv

I think the issue might be that the builtin importlib is preferred over the vendored version (https://github.com/explosion/catalogue/blob/master/catalogue/__init__.py#L4-L7), but changed its internal API between python3.9 and python3.10 and doesn't have that function.

Hi, we're aware that the test fails for 3.10, but we haven't had time to figure out how to update it or add a new equivalent test for 3.10. For now, we should add an official pytest skip as we did for the conda-forge package here:

https://github.com/conda-forge/catalogue-feedstock/blob/cc38d845cf7009f23df1ffbfdb3372fd1dba4942/recipe/patches/0001-skip-entry-points-test.patch

In all our downstream applications catalogue works fine with python 3.10, so I think it's really just a matter of the private methods in this particular test being an issue, not a problem with the library itself, although this is a pretty core test for it.

The vendored importlib-metadata is indeed only used in place of the separate importlib-metadata backport library, not instead of the builtin version for python 3.8+. (So we can hope that at some point in the future we no longer need to vendor it, but it's not going to be anytime soon.)