Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with importlib-metadata > 5.0 ('EntryPoints' object has no attribute 'get') #1550

Closed
jkerhin opened this issue Oct 5, 2022 · 4 comments

Comments

@jkerhin
Copy link

jkerhin commented Oct 5, 2022

Small description
Visidata is using the .get() method on the output of importlib.entry_points(). According to the authors, the .get() method was deprecated functionality, removed in version 5.0.0 (latest version). Discussion thread: python/importlib_metadata#409

The call that throws the error is this one: https://github.com/saulpw/visidata/blob/develop/visidata/settings.py#L378

Expected result
Visidata runs without issue

Actual result with screenshot

$ vd sample.csv
Traceback (most recent call last):
  File "/home/joe/.local/bin/vd", line 6, in <module>
    visidata.main.vd_cli()
  File "/home/joe/.local/pipx/venvs/visidata/lib/python3.10/site-packages/visidata/main.py", line 350, in vd_cli
    rc = main_vd()
  File "/home/joe/.local/pipx/venvs/visidata/lib/python3.10/site-packages/visidata/main.py", line 209, in main_vd
    vd.loadConfigAndPlugins(args)
  File "/home/joe/.local/pipx/venvs/visidata/lib/python3.10/site-packages/visidata/settings.py", line 378, in loadConfigAndPlugins
    for ep in entry_points().get('visidata.plugins', []):
AttributeError: 'EntryPoints' object has no attribute 'get'

Steps to reproduce with sample data and a .vd
Crashes before loading any data

Additional context

OS: Ubuntu Server 20.04
Python Version: 3.10.4
Environment: pipx

Reference:

$ pipx install visidata
  installed package visidata 2.10.1, installed using Python 3.10.4
  These apps are now globally available
    - vd
    - visidata
done! ✨ 🌟 ✨
@jkerhin jkerhin added the bug label Oct 5, 2022
@jkerhin
Copy link
Author

jkerhin commented Oct 5, 2022

Since I am not using any plugins, I can work around this in my local environment by just commenting out the block in setup.py that does the plugin loading.

I'm not at all familiar with entrypoints-metadata, and unfortunately am not able to identify a proper solution. It looks like the EntryPoints class can be iterated through, and each EntryPoint supports the in operator.

This may work, but again, I'm not familiar with entrypoints-metadata nor the Visidata plugin ecosystem:

eps = [e for e in entry_points() if "visidata.plugins" in e]

@anjakefala
Copy link
Collaborator

Oh, thank you so much @jkerhin for letting me know. =( importlib-metadata is more finicky than I would like.

The good news is that for future releases of VisiData, if anything goes wrong at any point with importlib-metadata, this feature will just get skipped instead of crashing. You can also do options.plugins_autoload = False in a ~/.visidatarc. It will do the same thing as commenting out the block.

@anjakefala
Copy link
Collaborator

This fix will be in the next patched release of VisiData. This gave us the nudge to push out the patch. Again, thanks so much for letting us know!

@anjakefala anjakefala pinned this issue Oct 6, 2022
@anjakefala anjakefala changed the title Crash due to deprecated importlib-metadata feature Crash with importlib-metadata > 5.0 ('EntryPoints' object has no attribute 'get') Oct 6, 2022
@anjakefala
Copy link
Collaborator

VisiData v2.10.2 has been released with all of the fixes for this issue. =)

@anjakefala anjakefala unpinned this issue May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants