Skip to content

Instantly share code, notes, and snippets.

@dcode
Last active August 8, 2023 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcode/bf02db939f76565b8eb5a914a13e552b to your computer and use it in GitHub Desktop.
Save dcode/bf02db939f76565b8eb5a914a13e552b to your computer and use it in GitHub Desktop.

When trying to use newer versions of pip on a remote headless system, it requires keyring access, or will at least use it if present. When running poetry installed via pipx, it installs keyring and it all breaks. Here's how I fixed it today.

Install development headers (assumes build tools already installed).

sudo apt install -y libkeyutils-dev

Enter the bin dir for the poetry pipx environment and install the keyutils extension for keyring.

cd $(dirname $(readlink -f $(which poetry)))
./pip3 install git+https://github.com/marcus-h/python-keyring-keyutils.git

Now configure keyring to use the new backend

kring_conf_root="$(python -c 'import keyring.util.platform_;print(keyring.util.platform_.config_root())')"
mkdir -p "${kring_conf_root}"
echo -e "[backend]\ndefault-keyring=keyutils.backend.KeyutilsKeyringBackend" > \
  "${kring_conf_root}/keyringrc.cfg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment