MCPcopy Index your code
hub / github.com/python/cpython / _uninstall_helper

Function _uninstall_helper

Lib/ensurepip/__init__.py:187–215  ·  view source on GitHub ↗

Helper to support a clean default uninstall process on Windows Note that calling this function may alter os.environ.

(*, verbosity=0)

Source from the content-addressed store, hash-verified

185
186
187def _uninstall_helper(*, verbosity=0):
188 """Helper to support a clean default uninstall process on Windows
189
190 Note that calling this function may alter os.environ.
191 """
192 # Nothing to do if pip was never installed, or has been removed
193 try:
194 import pip
195 except ImportError:
196 return
197
198 # If the installed pip version doesn't match the available one,
199 # leave it alone
200 available_version = version()
201 if pip.__version__ != available_version:
202 print(f"ensurepip will only uninstall a matching version "
203 f"({pip.__version__!r} installed, "
204 f"{available_version!r} available)",
205 file=sys.stderr)
206 return
207
208 _disable_pip_configuration_settings()
209
210 # Construct the arguments to be passed to the pip command
211 args = ["uninstall", "-y", "--disable-pip-version-check"]
212 if verbosity:
213 args += ["-" + "v" * verbosity]
214
215 return _run_pip([*args, "pip"])
216
217
218def _main(argv=None):

Callers

nothing calls this directly

Calls 3

_run_pipFunction · 0.85
versionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…