Helper to support a clean default uninstall process on Windows Note that calling this function may alter os.environ.
(*, verbosity=0)
| 185 | |
| 186 | |
| 187 | def _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 | |
| 218 | def _main(argv=None): |
nothing calls this directly
no test coverage detected
searching dependent graphs…