Repository: python/mypy

Issue:
Mypy uses pip for --install-types but does not list pip in requirements
<!--
  If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the "Question and Help" form
  instead.
  Please also consider:

  - checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html
  - searching our issue tracker: https://github.com/python/mypy/issues to see if
    it's already been reported
  - asking on gitter chat: https://gitter.im/python/typing
-->

**Bug Report**

<!--
Note: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues
-->

On Linux distributions packages such as mypy may be built using PEP517 methods by now. Packagers use a project's list of requirements to figure out what is required during build, test and runtime.
The same is true for minimal venvs in which only the specific set of packages are installed that are required to run a specific thing (e.g. mypy).
Mypy requires pip for `mypy --install-types` but does not list pip in its requirements. This leads to virtual environments that can not plainly list mypy as dependency and run `mypy --install-types`. The same is the case for users of given Linux distributions, that install mypy via their package manager (and do not install pip directly or via some other transitive dependency).

**To Reproduce**

1. On Arch Linux install mypy, but not pip (e.g. on a fresh system): `pacman -S mypy`
2. In a project that e.g. uses `aiofiles`, run `mypy --install-types -p my_project`

The same behavior can be gotten by creating a minimal project using e.g. pdm and adding only packages that do not require pip themselves.
When adding mypy there and doing a `pdm run mypy --install-types -p my_project` the same issue as above occurs.

**Expected Behavior**

<!--
  How did you expect your project to behave?
  It’s fine if you’re not sure your understanding is correct.
  Write down what you thought would happen. If you just expected no errors, you can delete this section.
-->

Pip is a requirement of mypy and therefore already available when running `mypy --install-types`.

**Actual Behavior**

<!--
  Did something go wrong?
  Is something broken, or not behaving as you expected?
-->

```
mypy --install-types -p repod
repod/repo/management/outputpackage.py:7: error: Library stubs not installed for "aiofiles" (or incompatible with Python 3.10)  [import]
repod/repo/management/outputpackage.py:7: note: Hint: "python3 -m pip install types-aiofiles"
repod/repo/management/outputpackage.py:7: note: (or run "mypy --install-types" to install all missing stub packages)
repod/repo/management/outputpackage.py:7: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 26 source files)

Installing missing stub packages:
/usr/bin/python -m pip install types-aiofiles

Install? [yN] y

/usr/bin/python: No module named pip

note: Run mypy again for up-to-date results with installed types
```

**Your Environment**

<!-- Include as many relevant details about the environment you experienced the bug in -->

- Mypy version used: 971
- Mypy command-line flags: `--install-types`
- Mypy configuration options from `mypy.ini` (and other config files): not relevant for this issue
- Python version used: 3.10.6
- Operating system and version: Arch Linux

<!--
You can freely edit this text, please remove all the lines
you believe are unnecessary.
-->



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -220,6 +220,7 @@ def run(self):
         "dmypy": "psutil >= 4.0",
         "python2": "typed_ast >= 1.4.0, < 2",
         "reports": "lxml",
+        "install-types": "pip",
     },
     python_requires=">=3.7",
     include_package_data=True,


Test patch: