Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pip/_vendor/__init__.py: 12%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2pip._vendor is for vendoring dependencies of pip to prevent needing pip to
3depend on something external.
5Files inside of pip._vendor should be considered immutable and should only be
6updated to versions from upstream.
7"""
8from __future__ import absolute_import
10import glob
11import os.path
12import sys
14# Downstream redistributors which have debundled our dependencies should also
15# patch this value to be true. This will trigger the additional patching
16# to cause things like "six" to be available as pip.
17DEBUNDLED = False
19# By default, look in this directory for a bunch of .whl files which we will
20# add to the beginning of sys.path before attempting to import anything. This
21# is done to support downstream re-distributors like Debian and Fedora who
22# wish to create their own Wheels for our dependencies to aid in debundling.
23WHEEL_DIR = os.path.abspath(os.path.dirname(__file__))
26# Define a small helper function to alias our vendored modules to the real ones
27# if the vendored ones do not exist. This idea of this was taken from
28# https://github.com/kennethreitz/requests/pull/2567.
29def vendored(modulename):
30 vendored_name = "{0}.{1}".format(__name__, modulename)
32 try:
33 __import__(modulename, globals(), locals(), level=0)
34 except ImportError:
35 # We can just silently allow import failures to pass here. If we
36 # got to this point it means that ``import pip._vendor.whatever``
37 # failed and so did ``import whatever``. Since we're importing this
38 # upfront in an attempt to alias imports, not erroring here will
39 # just mean we get a regular import error whenever pip *actually*
40 # tries to import one of these modules to use it, which actually
41 # gives us a better error message than we would have otherwise
42 # gotten.
43 pass
44 else:
45 sys.modules[vendored_name] = sys.modules[modulename]
46 base, head = vendored_name.rsplit(".", 1)
47 setattr(sys.modules[base], head, sys.modules[modulename])
50# If we're operating in a debundled setup, then we want to go ahead and trigger
51# the aliasing of our vendored libraries as well as looking for wheels to add
52# to our sys.path. This will cause all of this code to be a no-op typically
53# however downstream redistributors can enable it in a consistent way across
54# all platforms.
55if DEBUNDLED:
56 # Actually look inside of WHEEL_DIR to find .whl files and add them to the
57 # front of our sys.path.
58 sys.path[:] = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
60 # Actually alias all of our vendored dependencies.
61 vendored("cachecontrol")
62 vendored("certifi")
63 vendored("dependency-groups")
64 vendored("distlib")
65 vendored("distro")
66 vendored("packaging")
67 vendored("packaging.version")
68 vendored("packaging.specifiers")
69 vendored("pkg_resources")
70 vendored("platformdirs")
71 vendored("progress")
72 vendored("pyproject_hooks")
73 vendored("requests")
74 vendored("requests.exceptions")
75 vendored("requests.packages")
76 vendored("requests.packages.urllib3")
77 vendored("requests.packages.urllib3._collections")
78 vendored("requests.packages.urllib3.connection")
79 vendored("requests.packages.urllib3.connectionpool")
80 vendored("requests.packages.urllib3.contrib")
81 vendored("requests.packages.urllib3.contrib.ntlmpool")
82 vendored("requests.packages.urllib3.contrib.pyopenssl")
83 vendored("requests.packages.urllib3.exceptions")
84 vendored("requests.packages.urllib3.fields")
85 vendored("requests.packages.urllib3.filepost")
86 vendored("requests.packages.urllib3.packages")
87 vendored("requests.packages.urllib3.packages.ordered_dict")
88 vendored("requests.packages.urllib3.packages.six")
89 vendored("requests.packages.urllib3.packages.ssl_match_hostname")
90 vendored("requests.packages.urllib3.packages.ssl_match_hostname."
91 "_implementation")
92 vendored("requests.packages.urllib3.poolmanager")
93 vendored("requests.packages.urllib3.request")
94 vendored("requests.packages.urllib3.response")
95 vendored("requests.packages.urllib3.util")
96 vendored("requests.packages.urllib3.util.connection")
97 vendored("requests.packages.urllib3.util.request")
98 vendored("requests.packages.urllib3.util.response")
99 vendored("requests.packages.urllib3.util.retry")
100 vendored("requests.packages.urllib3.util.ssl_")
101 vendored("requests.packages.urllib3.util.timeout")
102 vendored("requests.packages.urllib3.util.url")
103 vendored("resolvelib")
104 vendored("rich")
105 vendored("rich.console")
106 vendored("rich.highlighter")
107 vendored("rich.logging")
108 vendored("rich.markup")
109 vendored("rich.progress")
110 vendored("rich.segment")
111 vendored("rich.style")
112 vendored("rich.text")
113 vendored("rich.traceback")
114 if sys.version_info < (3, 11):
115 vendored("tomli")
116 vendored("truststore")
117 vendored("urllib3")