pip still prompts for username/password even when keyring is configured
Description
I'm trying to download a package from a GitLab registry using credentials stored via keyring. I believe I am following the documentation but pip neither uses the keyring credentials nor displays an error and instead just prompts for username/password.
$ which pip
/home/timo/python_venvs/my_venv/bin/pip
$ which keyring
/home/timo/python_venvs/my_venv/bin/keyring
$ echo <MY_TOKEN> | keyring set https://gitlab.com/api/v4/groups/<MY_GROUP_ID>/-/packages/pypi/simple <MY_TOKEN_NAME>
$ pip install --keyring-provider import -i https://gitlab.com/api/v4/groups/<MY_GROUP_ID>/-/packages/pypi/simple <MY_PACKAGE>
User for gitlab.com:
...
Expected behavior
pip uses the credentials stored in keyring.
pip version
24.0
Python version
3.10.12
OS
Ubuntu 22.04.4 LTS
How to Reproduce
- Install pip and keyring
- Create a GitLab package registry and upload a Python package to it
- Create a GitLab access token with
read_apirights - Store the token via keyring
- Run
pip install --keyring-provider import -i https://gitlab.com/api/v4/groups/<MY_GROUP_ID>/-/packages/pypi/simple <MY_PACKAGE>
Output
No response
Code of Conduct
- [X] I agree to follow the PSF Code of Conduct.
Edit: nevermind, I was wrong: @Time0o is using --keyring-provider import, not subprocess.
~@Time0o, this looks likely to be a duplicate of https://github.com/pypa/pip/issues/12543. When using keyring as a subprocess, it can't discover the username. Workarounds are to either change your index url to include a username, or use keyring with the import provider, which does have support for keyring's get_credentials functionality to fetch both a password and a username.~
@Time0o, this looks likely to be a duplicate of #12543. When using keyring as a subprocess, it can't discover the username. Workarounds are to either change your index url to include a username, or use keyring with the import provider, which does have support for keyring's get_credentials functionality to fetch both a password and a username.
The reproducer includes --keyring-provider import, so I don't think your PR is relevant.