Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._internal.network.auth Namespace Reference

Data Structures

class  Credentials
 
class  KeyRingBaseProvider
 
class  KeyRingCliProvider
 
class  KeyRingNullProvider
 
class  KeyRingPythonProvider
 
class  MultiDomainBasicAuth
 

Functions

KeyRingBaseProvider get_keyring_provider (str provider)
 

Variables

 logger = getLogger(__name__)
 
bool KEYRING_DISABLED = False
 

Detailed Description

Network Authentication Helpers

Contains interface (MultiDomainBasicAuth) and associated glue code for
providing credentials in the context of network requests.

Function Documentation

◆ get_keyring_provider()

KeyRingBaseProvider get_keyring_provider ( str  provider)

Definition at line 162 of file auth.py.

162def get_keyring_provider(provider: str) -> KeyRingBaseProvider:
163 logger.verbose("Keyring provider requested: %s", provider)
164
165 # keyring has previously failed and been disabled
166 if KEYRING_DISABLED:
167 provider = "disabled"
168 if provider in ["import", "auto"]:
169 try:
170 impl = KeyRingPythonProvider()
171 logger.verbose("Keyring provider set: import")
172 return impl
173 except ImportError:
174 pass
175 except Exception as exc:
176 # In the event of an unexpected exception
177 # we should warn the user
178 msg = "Installed copy of keyring fails with exception %s"
179 if provider == "auto":
180 msg = msg + ", trying to find a keyring executable as a fallback"
182 if provider in ["subprocess", "auto"]:
183 cli = shutil.which("keyring")
184 if cli and cli.startswith(sysconfig.get_path("scripts")):
185 # all code within this function is stolen from shutil.which implementation
186 @typing.no_type_check
188 path = os.environ.get("PATH", None)
189 if path is None:
190 try:
191 path = os.confstr("CS_PATH")
192 except (AttributeError, ValueError):
193 # os.confstr() or CS_PATH is not available
194 path = os.defpath
195 # bpo-35755: Don't use os.defpath if the PATH environment variable is
196 # set to an empty string
197
198 return path
199
200 scripts = Path(sysconfig.get_path("scripts"))
201
202 paths = []
204 p = Path(path)
205 try:
206 if not p.samefile(scripts):
207 paths.append(path)
208 except FileNotFoundError:
209 pass
210
211 path = os.pathsep.join(paths)
212
213 cli = shutil.which("keyring", path=path)
214
215 if cli:
216 logger.verbose("Keyring provider set: subprocess with executable %s", cli)
217 return KeyRingCliProvider(cli)
218
219 logger.verbose("Keyring provider set: disabled")
220 return KeyRingNullProvider()
221
222
for i

Variable Documentation

◆ KEYRING_DISABLED

bool KEYRING_DISABLED = False

Definition at line 35 of file auth.py.

◆ logger

logger = getLogger(__name__)

Definition at line 33 of file auth.py.