nazarewk / keyring_pass

Password Store (pass) backend for python's keyring
MIT License
18 stars 5 forks source link

Version 0.8.0 not working on Python <3.9 #12

Closed bryanburke closed 1 year ago

bryanburke commented 1 year ago

Thank you for making this very useful Keyring backend for pass!

I am encountering AttributeError: module 'functools' has no attribute 'cache' when using keyring-pass 0.8.0 (latest version as of writing) on Python versions less than 3.9. keyring-pass may be using functools features that only became available with 3.9+. The README and PyPI package metadata indicate Python 3.7+ are supported, however.

Below is a minimal way to reproduce the error using Docker.

Python 3.9 (the failure at the end is expected due to pass not being installed):

$ docker run --rm -it --entrypoint "" -w /root python:3.9 bash -c 'pip install keyring-pass && mkdir -p ~/.config/python_keyring && echo "[backend]" >~/.config/pytho
n_keyring/keyringrc.cfg && echo "default-keyring = keyring_pass.PasswordStoreBackend" >>~/.config/python_keyring/keyringrc.cfg && keyring set https://example.com foobar'
Unable to find image 'python:3.9' locally
3.9: Pulling from library/python
bba7bb10d5ba: Already exists 
ec2b820b8e87: Already exists 
284f2345db05: Already exists 
fea23129f080: Already exists 
7c62c924b8a6: Already exists 
b2210932934e: Pull complete 
ee9c01829d92: Pull complete 
d6285f41f1b6: Pull complete 
Digest: sha256:98f018a1afd67f2e17a4abd5bfe09b998734ba7c1ee54780e7ed216f8b8095c3
Status: Downloaded newer image for python:3.9
Collecting keyring-pass
  Downloading keyring_pass-0.8.0-py3-none-any.whl (4.0 kB)
Collecting keyring<24.0.0,>=23.9.3
  Downloading keyring-23.13.1-py3-none-any.whl (37 kB)
Collecting jaraco-classes<4.0.0,>=3.2.3
  Downloading jaraco.classes-3.2.3-py3-none-any.whl (6.0 kB)
Collecting more-itertools
  Downloading more_itertools-9.1.0-py3-none-any.whl (54 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.2/54.2 kB 4.2 MB/s eta 0:00:00
Collecting importlib-metadata>=4.11.4
  Downloading importlib_metadata-6.7.0-py3-none-any.whl (22 kB)
Collecting jeepney>=0.4.2
  Downloading jeepney-0.8.0-py3-none-any.whl (48 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.4/48.4 kB 3.5 MB/s eta 0:00:00
Collecting SecretStorage>=3.2
  Downloading SecretStorage-3.3.3-py3-none-any.whl (15 kB)
Collecting zipp>=0.5
  Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)
Collecting cryptography>=2.0
  Downloading cryptography-41.0.1-cp37-abi3-manylinux_2_28_x86_64.whl (4.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 38.5 MB/s eta 0:00:00
Collecting cffi>=1.12
  Downloading cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.2/441.2 kB 26.1 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 5.9 MB/s eta 0:00:00
Installing collected packages: zipp, pycparser, more-itertools, jeepney, jaraco-classes, importlib-metadata, cffi, cryptography, SecretStorage, keyring, keyring-pass
Successfully installed SecretStorage-3.3.3 cffi-1.15.1 cryptography-41.0.1 importlib-metadata-6.7.0 jaraco-classes-3.2.3 jeepney-0.8.0 keyring-23.13.1 keyring-pass-0.8.0 more-itertools-9.1.0 pycparser-2.21 zipp-3.15.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: pip install --upgrade pip
Password for 'foobar' in 'https://example.com': 
Traceback (most recent call last):
  File "/usr/local/bin/keyring", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/keyring/cli.py", line 134, in main
    return cli.run(argv)
  File "/usr/local/lib/python3.9/site-packages/keyring/cli.py", line 70, in run
    return method()
  File "/usr/local/lib/python3.9/site-packages/keyring/cli.py", line 87, in do_set
    set_password(self.service, self.username, password)
  File "/usr/local/lib/python3.9/site-packages/keyring/core.py", line 60, in set_password
    get_keyring().set_password(service_name, username, password)
  File "/usr/local/lib/python3.9/site-packages/keyring/core.py", line 32, in get_keyring
    init_backend()
  File "/usr/local/lib/python3.9/site-packages/keyring/core.py", line 83, in init_backend
    set_keyring(_detect_backend(limit))
  File "/usr/local/lib/python3.9/site-packages/keyring/core.py", line 98, in _detect_backend
    or load_config()
  File "/usr/local/lib/python3.9/site-packages/keyring/core.py", line 177, in load_config
    return load_keyring(keyring_name)
  File "/usr/local/lib/python3.9/site-packages/keyring/core.py", line 136, in load_keyring
    class_.priority
  File "/usr/local/lib/python3.9/site-packages/jaraco/classes/properties.py", line 151, in __get__
    return self.fget.__get__(None, owner)()
  File "/usr/local/lib/python3.9/site-packages/keyring_pass/__init__.py", line 64, in priority
    raise RuntimeError(f"`{binary}` executable is missing!")
RuntimeError: `pass` executable is missing!

Python 3.8 (the AttributeError is not expected):

$ docker run --rm -it --entrypoint "" -w /root python:3.8 bash -c 'pip install keyring-pass && mkdir -p ~/.config/python_keyring && echo "[backend]" >~/.config/python_keyring/keyringrc.cfg && echo "default-keyring = keyring_pass.PasswordStoreBackend" >>~/.config/python_keyring/keyringrc.cfg && keyring set https://example.com foobar'
Collecting keyring-pass
  Downloading keyring_pass-0.8.0-py3-none-any.whl (4.0 kB)
Collecting keyring<24.0.0,>=23.9.3
  Downloading keyring-23.13.1-py3-none-any.whl (37 kB)
Collecting jaraco-classes<4.0.0,>=3.2.3
  Downloading jaraco.classes-3.2.3-py3-none-any.whl (6.0 kB)
Collecting more-itertools
  Downloading more_itertools-9.1.0-py3-none-any.whl (54 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.2/54.2 kB 1.7 MB/s eta 0:00:00
Collecting importlib-resources
  Downloading importlib_resources-5.12.0-py3-none-any.whl (36 kB)
Collecting SecretStorage>=3.2
  Downloading SecretStorage-3.3.3-py3-none-any.whl (15 kB)
Collecting jeepney>=0.4.2
  Downloading jeepney-0.8.0-py3-none-any.whl (48 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.4/48.4 kB 1.9 MB/s eta 0:00:00
Collecting importlib-metadata>=4.11.4
  Downloading importlib_metadata-6.7.0-py3-none-any.whl (22 kB)
Collecting zipp>=0.5
  Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)
Collecting cryptography>=2.0
  Downloading cryptography-41.0.1-cp37-abi3-manylinux_2_28_x86_64.whl (4.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 3.7 MB/s eta 0:00:00
Collecting cffi>=1.12
  Downloading cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (442 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 442.7/442.7 kB 4.5 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 9.1 MB/s eta 0:00:00
Installing collected packages: zipp, pycparser, more-itertools, jeepney, jaraco-classes, importlib-resources, importlib-metadata, cffi, cryptography, SecretStorage, keyring, keyring-pass
Successfully installed SecretStorage-3.3.3 cffi-1.15.1 cryptography-41.0.1 importlib-metadata-6.7.0 importlib-resources-5.12.0 jaraco-classes-3.2.3 jeepney-0.8.0 keyring-23.13.1 keyring-pass-0.8.0 more-itertools-9.1.0 pycparser-2.21 zipp-3.15.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: pip install --upgrade pip
Password for 'foobar' in 'https://example.com': 
Traceback (most recent call last):
  File "/usr/local/bin/keyring", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/keyring/cli.py", line 134, in main
    return cli.run(argv)
  File "/usr/local/lib/python3.8/site-packages/keyring/cli.py", line 70, in run
    return method()
  File "/usr/local/lib/python3.8/site-packages/keyring/cli.py", line 87, in do_set
    set_password(self.service, self.username, password)
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 60, in set_password
    get_keyring().set_password(service_name, username, password)
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 32, in get_keyring
    init_backend()
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 83, in init_backend
    set_keyring(_detect_backend(limit))
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 98, in _detect_backend
    or load_config()
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 177, in load_config
    return load_keyring(keyring_name)
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 134, in load_keyring
    class_ = _load_keyring_class(keyring_name)
  File "/usr/local/lib/python3.8/site-packages/keyring/core.py", line 124, in _load_keyring_class
    __import__(module_name)
  File "/usr/local/lib/python3.8/site-packages/keyring_pass/__init__.py", line 28, in <module>
    @functools.cache
AttributeError: module 'functools' has no attribute 'cache'

Thank you for your time!

nazarewk commented 1 year ago

this is fixed by #11 , I will release the new version