-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add pip to install_requires #13739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pip to install_requires #13739
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rarely see envs without pip but with mypy installed.
I don't really know how one can even do that: by running python mypy/setup.py install
locally?
That might be, but relying on transitive dependencies of some other package to pull in pip is less than ideal (basically broken).
This can happen if one does not specifically add it to the project's requirements. Tools such as PDM and also poetry will not install pip to your venv, if it is technically not required. If mypy does not pull in pip specifically and no other dependency does, a build container in CI only installing e.g. pdm and then bootstrapping the project requirements will not have pip. |
~/Desktop
» mkdir test && cd test
~/Desktop/test
» poetry --version && poetry init
Poetry (version 1.2.1)
This command will guide you through creating your pyproject.toml config.
Package name [test]:
Version [0.1.0]:
Description []:
Author [sobolevn <mail@sobolevn.me>, n to skip]:
License []:
Compatible Python versions [^3.10]:
Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["sobolevn <mail@sobolevn.me>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Do you confirm generation? (yes/no) [yes]
~/Desktop/test
» poetry install
Creating virtualenv test in /Users/sobolev/Desktop/test/.venv
Updating dependencies
Resolving dependencies... (0.1s)
Writing lock file
~/Desktop/test
» poetry run which pip
/Users/sobolev/Desktop/test/.venv/bin/pip |
Yeah, my bad (didn't check up on poetry again before writing my reply). I guess this only extents to PDM then (it does not install pip into the venv, but would instead rely on the system-wide installed pip if it is available) and poetry somehow installs some magic packages into the venv. 🤔 Either way, a dependency on pip is a requirement if it is needed. Not all environments install their python packages using pip (e.g. all downstream distributions use system package management for that). So currently I don't have pip installed and have a fully functioning Python environment. |
83fa6ea
to
8deffa5
Compare
This comment has been minimized.
This comment has been minimized.
setup.py: Change `setup()` call to include pip in the list of extra dependencies passed to `extra_requires`. Pip is required for the `mypy --install-types` feature. Without specifically adding it, minimal environments (e.g. venvs created using PDM) will not have pip installed and therefore have no way of installing required types (e.g. for tests).
8deffa5
to
9ba4f1f
Compare
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
I'm not quite sure and hence am seeking for assistance: recently I found that MyPy cannot install |
@yermulnik I don't believe this is related. pip has been added as an optional dependency only, installable by keyword (i.e. |
setup.py:
Change
setup()
call to include pip in the list of dependencies passed toinstall_requires
.Pip is required for the
mypy --install-types
feature. Without specifically adding it, minimal environments (e.g. venvs) will not have pip installed and therefore have no way of installing required types (e.g. for tests).Fixes #13580