mitya57 / secretstorage

Python bindings to Freedesktop.org Secret Service API
https://secretstorage.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
106 stars 21 forks source link

ImportError: No module named gi.repository #8

Closed janssen closed 7 years ago

janssen commented 7 years ago

I'm seeing this failure:

  File "build/bdist.linux-x86_64/egg/secretstorage/collection.py", line 158, in get_default_collection
  File "build/bdist.linux-x86_64/egg/secretstorage/collection.py", line 137, in create_collection
  File "build/bdist.linux-x86_64/egg/secretstorage/util.py", line 127, in exec_prompt_glib
ImportError: No module named gi.repository

Apparently there is also a dependency on some module 'gi'?

mitya57 commented 7 years ago

Right, if you want to use the synchronous API, you need to install the Python GI bindings (aka PyGObject).

They cannot be installed from PyPI, but they are available in e.g. python3-gi package on Debian/Ubuntu.

janssen commented 7 years ago

Unfortunately, I need secretstorage for a venv, that doesn't use the system Python, and I don't see any easy way to install the bindings there. How about catching the ImportError and just prompting using Python's "input" (or "raw_input" on Python 2) if that happens?

mitya57 commented 7 years ago

What is your use case? One of the key points of Secret Service is its integration with the desktop environments, so input will simply make no sense here (and it's also not available in GUI applications).

If you need some simple API to store passwords in a command-line application, I think you should use something like python-keyring instead, which has, among others, an encrypted file backend.

If you really need desktop integration and want to use it from virtualenv, you can build PyGObject yourself from the source code.

Finally, you can install PyQt5 from PyPI and use it instead of PyGObject to implement the main loop. In this case you will need to use exec_prompt_qt function of SecretStorage (or your own callback).

janssen commented 7 years ago

I'm running a command-line program that uses Python keyring to store secrets which allow it to communicate with a Web service (basically, a secure cookie, via keyringcookiejar). We want to use the user's login store for this, not an extra encrypted file that has to be locked and unlocked each time. We want this to work the same way it does on the Mac, where the keyring backend talks to the login keychain of the user. Prompting for the password using "raw_input" would work well for this.

janssen commented 7 years ago

What I'd really like is some option in secretstorage which would allow the user to select what method to use to get information from the user via a prompt.

mitya57 commented 7 years ago

The prompting is done not by SecretStorage. It is just a wrapper around the D-Bus API, the actual prompting is done by the server side (i.e. gnome-keyring). We have no control over this.

See the specification for details.