@@ -66,18 +66,21 @@ man pages][netrc-docs].
66
66
## Keyring Support
67
67
68
68
pip supports loading credentials stored in your keyring using the
69
- {pypi}` keyring ` library which can be enabled py passing ` --keyring-provider `
70
- with a value of ` auto ` , ` disabled ` , ` import ` or ` subprocess ` . The default value
71
- is ` auto ` . ` auto ` will respect ` --no-input ` and not query keyring at all if that
72
- option is used. The ` auto ` provider will use the ` import ` provider if the
73
- ` keyring ` module can be imported. If that is not the case it will use the
74
- ` subprocess ` provider if a ` keyring ` executable can be found. Otherwise, the
75
- ` disabled ` provider will be used.
76
-
77
- ### Configuring Pip
78
- Passing this as a command line argument will work, but is not how the majority
79
- of this feature's users will use it. They instead will want to overwrite the
80
- default of ` disabled ` in the global, user of site configuration file:
69
+ {pypi}` keyring ` library, which can be enabled py passing ` --keyring-provider `
70
+ with a value of ` auto ` , ` disabled ` , ` import ` , or ` subprocess ` . The default
71
+ value ` auto ` respects ` --no-input ` and not query keyring at all if the option
72
+ is used; otherwise it tries the ` import ` , ` subprocess ` , and ` disabled `
73
+ providers (in this order) and uses the first one that works.
74
+
75
+ ### Configuring pip's keyring usage
76
+
77
+ Since the keyring configuration is likely system-wide, a more common way to
78
+ configure its usage would be to use a configuration instead:
79
+
80
+ ``` {seealso}
81
+ {doc}`./configuration` describes how pip configuration works.
82
+ ```
83
+
81
84
``` bash
82
85
$ pip config set --global global.keyring-provider subprocess
83
86
@@ -95,10 +98,10 @@ $ pip config set --site global.keyring-provider disabled
95
98
$ export PIP_KEYRING_PROVIDER=disabled
96
99
```
97
100
98
- ### Installing and using the keyring python module
101
+ ### Using keyring's Python module
99
102
100
- Setting it to ` import ` tries to communicate with ` keyring ` by importing it
101
- and using its Python api .
103
+ Setting ` keyring-provider ` to ` import ` makes pip communicate with ` keyring ` via
104
+ its Python interface .
102
105
103
106
``` bash
104
107
# install keyring from PyPI
@@ -107,29 +110,28 @@ $ echo "your-password" | keyring set pypi.company.com your-username
107
110
$ pip install your-package --keyring-provider import --index-url https://pypi.company.com/
108
111
```
109
112
110
- ### Installing and using the keyring cli application
113
+ ### Using keyring as a command line application
111
114
112
- Setting it to ` subprocess ` will look for a ` keyring ` executable on the PATH
113
- if one can be found that is different from the ` keyring ` installation ` import `
114
- would be using.
115
+ Setting ` keyring-provider ` to ` subprocess ` makes pip look for and use the
116
+ ` keyring ` command found on ` PATH ` .
115
117
116
- The cli requires a username, therefore you MUST put a username in the url.
117
- See the example below or the basic HTTP authentication section at the top of
118
- this page.
118
+ For this use case, a username * must * be included in the URL, since it is
119
+ required by ` keyring ` 's command line interface. See the example below or the
120
+ basic HTTP authentication section at the top of this page.
119
121
120
122
``` bash
121
- # install keyring from PyPI using pipx, which we assume if installed properly
123
+ # Install keyring from PyPI using pipx, which we assume if installed properly
122
124
# you can also create a venv somewhere and add it to the PATH yourself instead
123
125
$ pipx install keyring --index-url https://pypi.org/simple
124
126
125
- # install the keyring backend for Azure DevOps for example
126
- # VssSessionToken is the username you MUST use for this backend
127
+ # For Azure DevOps, also install its keyring backend.
127
128
$ pipx inject keyring artifacts-keyring --index-url https://pypi.org/simple
128
129
129
- # or the one for Google Artifact Registry
130
+ # For Google Artifact Registry, also install and initialize its keyring backend.
130
131
$ pipx inject keyring keyrings.google-artifactregistry-auth --index-url https://pypi.org/simple
131
132
$ gcloud auth login
132
133
134
+ # Note that a username is required in the index URL.
133
135
$ pip install your-package --keyring-provider subprocess --index-url https://
[email protected] /
134
136
```
135
137
@@ -155,13 +157,13 @@ $ export PIP_KEYRING_PROVIDER=import
155
157
```
156
158
157
159
``` {warning}
158
- Be careful when doing this since it could cause tools such as Pipx and Pipenv
160
+ Be careful when doing this since it could cause tools such as pipx and Pipenv
159
161
to appear to hang. They show their own progress indicator while hiding output
160
162
from the subprocess in which they run Pip. You won't know whether the keyring
161
163
backend is waiting the user input or not in such situations.
162
164
```
163
165
164
- Pip is conservative and does not query keyring at all when ` --no-input ` is used
166
+ pip is conservative and does not query keyring at all when ` --no-input ` is used
165
167
because the keyring might require user interaction such as prompting the user
166
168
on the console. You can force keyring usage by passing ` --force-keyring ` or one
167
169
of the following:
@@ -174,7 +176,7 @@ $ export PIP_FORCE_KEYRING=1
174
176
```
175
177
176
178
``` {warning}
177
- Be careful when doing this since it could cause tools such as Pipx and Pipenv
179
+ Be careful when doing this since it could cause tools such as pipx and Pipenv
178
180
to appear to hang. They show their own progress indicator while hiding output
179
181
from the subprocess in which they run Pip. You won't know whether the keyring
180
182
backend is waiting the user input or not in such situations.
0 commit comments