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

KeyError: 'keyring.backends' Windows 10 - Keyring 21.2.0 with cx_freeze #426

Closed
mrichez-saluc opened this issue Mar 17, 2020 · 1 comment

Comments

@mrichez-saluc
Copy link

mrichez-saluc commented Mar 17, 2020

I'm using keyring in python project compiled with cx_freeze on Windows 10...
Got this error:

File "C:/msys64/mingw64/lib/python3.8/site-packages/keyring/core.py", line 192, in <module>
    init_backend()
  File "C:/msys64/mingw64/lib/python3.8/site-packages/keyring/core.py", line 96, in init_backend
    filter(limit, backend.get_all_keyring()),
  File "C:/msys64/mingw64/lib/python3.8/site-packages/keyring/util/__init__.py", line 22, in wrapper
    func.always_returns = func(*args, **kwargs)
  File "C:/msys64/mingw64/lib/python3.8/site-packages/keyring/backend.py", line 216, in get_all_keyring
    _load_plugins()
  File "C:/msys64/mingw64/lib/python3.8/site-packages/keyring/backend.py", line 199, in _load_plugins
    entry_points = metadata.entry_points()['keyring.backends']

KeyError: 'keyring.backends'

In my python-env :
keyring 21.2.0
keyrings.alt 3.4.0

In my code, i'm doing this:

...
import keyring
from keyring.backends import Windows
...
class MyProgram():
    def __init__(self):
        if platform.system() == "Windows":
            keyring.set_keyring(Windows.WinVaultKeyring())
        self.main()

Here's a part of setup-freeze.py:

...
setup(name='myprogram',
    version=version,
    options={
        'build_exe': {
            'no_compress': True,
            'include_files': include_files,
            'silent': True,
            'excludes': ['tcl', 'Tkinter'],
            'packages': ['gi', 'keyring', 'keyring.backends', 'keyrings.alt', 'requests', 'win32ctypes'],
            'include_msvcr': True,
            },
...

To have a working executable, i've to switch to keyring 18.0.1
Thanks for help!

@mrichez-saluc mrichez-saluc changed the title KeyError: 'keyring.backends' Windows 10 - Keyring 21.2.0 KeyError: 'keyring.backends' Windows 10 - Keyring 21.2.0 with cx_freeze Mar 17, 2020
@jaraco
Copy link
Owner

jaraco commented Apr 30, 2020

The problem here is that cx_Freeze is not supplying the necessary metadata, so keyring.backends doesn't exist.

I agree keyring should perhaps behave nicer when the metadata isn't available, especially if you're setting they keyring explicitly as I see you are. Probably this issue was introduced in a9fe227, released with 19.3.0.

Someone attempted to solve this issue (or something similar in #422). I'll see if I can put together a fix that includes a test and a less aggressive patch.

jaraco added a commit that referenced this issue Apr 30, 2020
@jaraco jaraco closed this as completed in 7922cbd Apr 30, 2020
jaraco added a commit that referenced this issue Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants